taffy/util/
mod.rs

1//! Helpful misc. utilities such as a function to debug print a tree
2mod math;
3mod resolve;
4pub(crate) mod sys;
5
6pub use math::MaybeMath;
7pub use resolve::{MaybeResolve, ResolveOrZero};
8
9#[doc(hidden)]
10#[macro_use]
11pub(crate) mod debug;
12
13#[cfg(feature = "std")]
14mod print;
15#[cfg(feature = "std")]
16pub use print::print_tree;
17
18/// Deserialize a type `S` by deserializing a string, then using the `FromStr`
19/// impl of `S` to create the result. The generic type `S` is not required to
20/// implement `Deserialize`.
21#[cfg(feature = "serde")]
22pub(crate) fn deserialize_from_str<'de, S, D>(deserializer: D) -> Result<S, D::Error>
23where
24    S: for<'a> From<&'a str>,
25    D: serde::Deserializer<'de>,
26{
27    let s: String = serde::Deserialize::deserialize(deserializer)?;
28    Ok(S::from(&s))
29}