[−][src]Function rudano::ser::to_string_pretty
pub fn to_string_pretty<T: Serialize>(value: &T) -> Result<String>
Serializes the given value
as a String of pretty-printed Rudano.
This will generate newlines, indentation, etc.
If you're looking for generating compact Rudano, use to_string_compact
instead.
Example
use serde::{Serialize, Deserialize}; #[derive(Serialize, Deserialize)] struct MyStruct { number: i32, string: String, } let value = MyStruct { number: 69, string: "nice".to_string(), }; let string = rudano::to_string_pretty(&value).unwrap(); let expected = r#"MyStruct { number: 69, string: "nice", }"#; assert_eq!(string, expected);
Errors
Serialization can fail if the structure's Serialize implementation or itoa fails.