to_string

Function to_string 

Source
pub fn to_string<T: Serialize>(value: &T) -> Result<String, Error>
Expand description

Serialize a value to a YAML String.

This is the easiest entry point when you just want a YAML string.

Example

use serde::Serialize;

#[derive(Serialize)]
struct Foo { a: i32, b: bool }

let s = serde_saphyr::to_string(&Foo { a: 1, b: true }).unwrap();
assert!(s.contains("a: 1"));