This is supported on crate feature
serde only.Expand description
A type that can deserialize from any data to string type.
It just like Yaml but no null value, anchor type and containers.
Calling ToString::to_string can convert the data into string.
use serde::Deserialize;
use yaml_peg::{node, serde::Stringify};
#[derive(Deserialize)]
struct Content {
width: Stringify,
}
let n_value = node!({"width" => 20});
let n_percent = node!({"width" => "20%"});
let value = Content::deserialize(n_value).unwrap();
let percent = Content::deserialize(n_percent).unwrap();
assert_eq!("20", value.width.to_string());
assert_eq!("20%", percent.width.to_string());Variants
Bool(bool)
Boolean value.
Int(i32)
Integer value.
Float(f32)
Float value.
Str(String)
String value.
Trait Implementations
sourceimpl<'de> Deserialize<'de> for Stringify
impl<'de> Deserialize<'de> for Stringify
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for Stringify
Auto Trait Implementations
impl RefUnwindSafe for Stringify
impl Send for Stringify
impl Sync for Stringify
impl Unpin for Stringify
impl UnwindSafe for Stringify
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more