Enum yaml_peg::serialize::Stringify[][src]

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 YamlBase 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, serialize::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.

Tuple Fields of Bool

0: bool
Int(i32)

Integer value.

Tuple Fields of Int

0: i32
Float(f32)

Float value.

Tuple Fields of Float

0: f32
Str(String)

String value.

Tuple Fields of Str

0: String

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

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

Converts the given value to a String. 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

Performs the conversion.

Performs the conversion.

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.