39 lines
818 B
Rust
39 lines
818 B
Rust
extern crate sehn;
|
|
|
|
use std::collections::BTreeMap;
|
|
|
|
use sehn::*;
|
|
|
|
fn print_and_clear(s: BaseSerializer<DefaultConfig, &mut StringWriter>) {
|
|
let out = s.into_inner();
|
|
println!("{}", out.as_str().unwrap());
|
|
out.clear();
|
|
}
|
|
|
|
fn main() {
|
|
let mut w = StringWriter::new();
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
let mut s = default_base_serializer(&mut w);
|
|
let mut obj = BTreeMap::new();
|
|
|
|
obj.insert("hello", Tag::new("one", vec![1]));
|
|
obj.insert("world", Tag::new("two", vec![2]));
|
|
|
|
s.serialize_any(obj).unwrap();
|
|
print_and_clear(s);
|
|
|
|
///////////////////////////////////////////////////////////////////////////
|
|
|
|
let mut s = default_base_serializer(&mut w);
|
|
|
|
let lines = vec![
|
|
"hello",
|
|
"world"
|
|
];
|
|
|
|
s.serialize_multiline_text(lines).unwrap();
|
|
print_and_clear(s);
|
|
}
|