Uses old Rust 2015
0.1.1 |
|
---|---|
0.1.0 |
|
#9 in #serializer
24KB
364 lines
YASS serializer
Example
#[macro_use]
extern crate yass;
extern crate yass_serializer;
fn main() {
let document = yass_document!(
("example")
"key1": r#""value1""#,
"key2": "value2",
"key3": "-1.0"
);
let serialize_style = yass_serializer::SerializeStyle::Spaced {
line_break_type: yass_serializer::LineBreakType::Lf,
indent_type: yass_serializer::IndentType::Space,
indent_length: 2,
};
let serialized = serialize_style.serialize_as_string(&document);
// (example)
// key1 "value1"
// key2 value2
// key3 -1.0
let expected = "(example)\nkey1 \"value1\"\nkey2 value2\nkey3 -1.0";
// Note that the serializer won't add a empty line at the end of the output
assert_eq!(serialized, expected);
}