1
Fork 0

auto merge of #10727 : erickt/rust/json, r=huonw

This PR does some small modernizations to the json library. First is to remove the `@` boxes, second is to rename the constructors to `new`.
This commit is contained in:
bors 2013-11-30 06:06:42 -08:00
commit 9bf62f71bc
7 changed files with 200 additions and 195 deletions

View file

@ -283,7 +283,7 @@ fn json_input(input: &str) -> Result<Output, ~str> {
}
let crate = match obj.pop(&~"crate") {
Some(json) => {
let mut d = json::Decoder(json);
let mut d = json::Decoder::init(json);
Decodable::decode(&mut d)
}
None => return Err(~"malformed json"),
@ -312,9 +312,12 @@ fn json_output(crate: clean::Crate, res: ~[plugins::PluginJson], dst: Path) {
// FIXME #8335: yuck, Rust -> str -> JSON round trip! No way to .encode
// straight to the Rust JSON representation.
let crate_json_str = {
let w = @mut MemWriter::new();
crate.encode(&mut json::Encoder(w as @mut io::Writer));
str::from_utf8(*w.inner_ref())
let mut w = MemWriter::new();
{
let mut encoder = json::Encoder::init(&mut w as &mut io::Writer);
crate.encode(&mut encoder);
}
str::from_utf8_owned(w.inner())
};
let crate_json = match json::from_str(crate_json_str) {
Ok(j) => j,