pub enum Stringify {
    Bool(bool),
    Int(i32),
    Float(f32),
    Str(String),
}
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

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Deserialize this value from the given Serde deserializer. Read more

Formats the value using the given formatter. Read more

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Converts the given value to a String. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.