pub fn to_string(any: &impl Serialize) -> Result<String, SerdeError>
This is supported on crate feature
serde
only.Expand description
Serialize data into Node
then dump into string.
use serde::Serialize;
use yaml_peg::serialize::to_string;
#[derive(Serialize)]
struct Member<'a> {
name: &'a str,
married: bool,
age: u8,
}
let officer = Member {
name: "Bob",
married: true,
age: 46,
};
let officer_doc = "\
name: Bob
married: true
age: 46
";
assert_eq!(officer_doc, to_string(&officer).unwrap());