tidy
This commit is contained in:
parent
fe82374328
commit
394f8eeb7e
2 changed files with 13 additions and 11 deletions
|
@ -121,21 +121,21 @@ pub impl Encoder: serialize::Encoder {
|
||||||
fn emit_owned(&self, f: fn()) { f() }
|
fn emit_owned(&self, f: fn()) { f() }
|
||||||
fn emit_managed(&self, f: fn()) { f() }
|
fn emit_managed(&self, f: fn()) { f() }
|
||||||
|
|
||||||
fn emit_enum(&self, name: &str, f: fn()) {
|
fn emit_enum(&self, _name: &str, f: fn()) {
|
||||||
f()
|
f()
|
||||||
}
|
}
|
||||||
|
|
||||||
fn emit_enum_variant(&self, _name: &str, id: uint, _cnt: uint, f: fn()) {
|
fn emit_enum_variant(&self, name: &str, _id: uint, _cnt: uint, f: fn()) {
|
||||||
// emitting enums as arrays where the first
|
// emitting enums as arrays where the first
|
||||||
// element provides the enum variant name
|
// element provides the enum variant name
|
||||||
self.wr.write_char('[');
|
self.wr.write_char('[');
|
||||||
self.wr.write_str(escape_str(_name));
|
self.wr.write_str(escape_str(name));
|
||||||
self.wr.write_char(',');
|
self.wr.write_char(',');
|
||||||
f();
|
f();
|
||||||
self.wr.write_char(']');
|
self.wr.write_char(']');
|
||||||
}
|
}
|
||||||
fn emit_enum_variant_arg(&self, _idx: uint, f: fn()) {
|
fn emit_enum_variant_arg(&self, idx: uint, f: fn()) {
|
||||||
if _idx != 0 {self.wr.write_char(',');}
|
if idx != 0 {self.wr.write_char(',');}
|
||||||
f();
|
f();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -1160,8 +1160,7 @@ mod test {
|
||||||
use core::io;
|
use core::io;
|
||||||
use core::str;
|
use core::str;
|
||||||
use std;
|
use std;
|
||||||
|
|
||||||
|
|
||||||
#[auto_decode]
|
#[auto_decode]
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
struct Node {id: uint}
|
struct Node {id: uint}
|
||||||
|
@ -1171,9 +1170,11 @@ mod test {
|
||||||
val.encode(~std::json::Encoder(bw as io::Writer));
|
val.encode(~std::json::Encoder(bw as io::Writer));
|
||||||
str::from_bytes(bw.bytes.data)
|
str::from_bytes(bw.bytes.data)
|
||||||
}
|
}
|
||||||
|
|
||||||
#[test] fn encode_test () {
|
#[test] fn encode_test () {
|
||||||
check_equal (to_json_str(Node{id:34} as Encodable::<std::json::Encoder>),~"{\"id\":34}");
|
check_equal (to_json_str(Node{id:34}
|
||||||
|
as Encodable::<std::json::Encoder>),
|
||||||
|
~"{\"id\":34}");
|
||||||
}
|
}
|
||||||
|
|
||||||
#[auto_encode]
|
#[auto_encode]
|
||||||
|
@ -1185,7 +1186,8 @@ mod test {
|
||||||
#[test] fn json_enum_encode_test () {
|
#[test] fn json_enum_encode_test () {
|
||||||
check_equal (to_json_str(Book(9) as Encodable::<std::json::Encoder>),
|
check_equal (to_json_str(Book(9) as Encodable::<std::json::Encoder>),
|
||||||
~"[\"Book\",9]");
|
~"[\"Book\",9]");
|
||||||
check_equal (to_json_str(Magazine(~"Paris Match") as Encodable::<std::json::Encoder>),
|
check_equal (to_json_str(Magazine(~"Paris Match")
|
||||||
|
as Encodable::<std::json::Encoder>),
|
||||||
~"[\"Magazine\",\"Paris Match\"]");
|
~"[\"Magazine\",\"Paris Match\"]");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue