gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

HTML 5544Rust 89Markdown 11TOML 91930 Definiciones

⎇ be975378e34b7c7892b983971819999809e713b8 src/util/mod.rs Rust · 31 líneas · 835 B Historia Quién tocó qué crudo

Add write_tree method (#925) be975378e · Elchanan Haas ·

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#[cfg(feature = "std")]
18pub use print::write_tree;
19
20/// Deserialize a type `S` by deserializing a string, then using the `FromStr`
21/// impl of `S` to create the result. The generic type `S` is not required to
22/// implement `Deserialize`.
23#[cfg(feature = "serde")]
24pub(crate) fn deserialize_from_str<'de, S, D>(deserializer: D) -> Result<S, D::Error>
25where
26    S: for<'a> From<&'a str>,
27    D: serde::Deserializer<'de>,
28{
29    let s: String = serde::Deserialize::deserialize(deserializer)?;
30    Ok(S::from(&s))
31}