[−][src]Function rudano::ser::to_string_compact
pub fn to_string_compact<T: Serialize>(value: &T) -> Result<String>
Serializes the given value
as a String of compact Rudano.
The compact representation of Rudano includes no whitespace or trailing comma.
If you're looking for pretty-printed Rudano, use to_string_pretty
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_compact(&value).unwrap(); let expected = r#"MyStruct{number:69,string:"nice"}"#; assert_eq!(string, expected);
Errors
Serialization can fail if the structure's Serialize implementation fails.