auto merge of #5630 : erickt/rust/serial, r=erickt
@nikomatsakis and I were talking about how the serializers were a bit too complicated. None of the users of With the `emit_option` and `read_option` functions, the serializers are now moving more high level. This patch series continues that trend. I've removed support for emitting specific string and vec types, and added support for emitting mapping types.
This commit is contained in:
commit
6dd20c8186
14 changed files with 845 additions and 767 deletions
|
|
@ -22,21 +22,9 @@ use EBWriter = std::ebml::writer;
|
|||
use core::cmp::Eq;
|
||||
use core::io::Writer;
|
||||
use std::ebml;
|
||||
use std::prettyprint;
|
||||
use std::serialize::{Encodable, Decodable};
|
||||
use std::time;
|
||||
|
||||
fn test_prettyprint<A:Encodable<prettyprint::Serializer>>(
|
||||
a: &A,
|
||||
expected: &~str
|
||||
) {
|
||||
let s = do io::with_str_writer |w| {
|
||||
a.encode(&prettyprint::Serializer(w))
|
||||
};
|
||||
debug!("s == %?", s);
|
||||
assert!(s == *expected);
|
||||
}
|
||||
|
||||
fn test_ebml<A:
|
||||
Eq +
|
||||
Encodable<EBWriter::Encoder> +
|
||||
|
|
@ -149,36 +137,27 @@ enum CLike { A, B, C }
|
|||
|
||||
pub fn main() {
|
||||
let a = &Plus(@Minus(@Val(3u), @Val(10u)), @Plus(@Val(22u), @Val(5u)));
|
||||
test_prettyprint(a, &~"Plus(@Minus(@Val(3u), @Val(10u)), \
|
||||
@Plus(@Val(22u), @Val(5u)))");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &Spanned {lo: 0u, hi: 5u, node: 22u};
|
||||
test_prettyprint(a, &~"Spanned {lo: 0u, hi: 5u, node: 22u}");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &Point {x: 3u, y: 5u};
|
||||
test_prettyprint(a, &~"Point {x: 3u, y: 5u}");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &@[1u, 2u, 3u];
|
||||
test_prettyprint(a, &~"@[1u, 2u, 3u]");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &Top(22u);
|
||||
test_prettyprint(a, &~"Top(22u)");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &Bottom(222u);
|
||||
test_prettyprint(a, &~"Bottom(222u)");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &A;
|
||||
test_prettyprint(a, &~"A");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &B;
|
||||
test_prettyprint(a, &~"B");
|
||||
test_ebml(a);
|
||||
|
||||
let a = &time::now();
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue