Skip to content

Commit

Permalink
extra: missed a couple @ in json
Browse files Browse the repository at this point in the history
  • Loading branch information
erickt committed Nov 30, 2013
1 parent 6818b96 commit a7b311a
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 15 deletions.
18 changes: 9 additions & 9 deletions src/libextra/json.rs
Original file line number Diff line number Diff line change
Expand Up @@ -464,7 +464,7 @@ impl Json{
pub fn to_pretty_str(&self) -> ~str {
let mut s = MemWriter::new();
self.to_pretty_writer(&mut s as &mut io::Writer);
str::from_utf8(s.inner_ref().as_slice())
str::from_utf8_owned(s.inner())
}
}

Expand Down Expand Up @@ -847,7 +847,7 @@ impl<T : Iterator<char>> Parser<T> {

/// Decodes a json value from an `&mut io::Reader`
pub fn from_reader(rdr: &mut io::Reader) -> Result<Json, Error> {
let s = str::from_utf8(rdr.read_to_end());
let s = str::from_utf8_owned(rdr.read_to_end());
let mut parser = Parser::init(s.chars());
parser.parse()
}
Expand Down Expand Up @@ -1319,9 +1319,9 @@ impl<A:ToJson> ToJson for Option<A> {
impl to_str::ToStr for Json {
/// Encodes a json value into a string
fn to_str(&self) -> ~str {
let s = @mut MemWriter::new();
self.to_writer(s as @mut io::Writer);
str::from_utf8(s.inner_ref().as_slice())
let mut s = MemWriter::new();
self.to_writer(&mut s as &mut io::Writer);
str::from_utf8_owned(s.inner())
}
}

Expand Down Expand Up @@ -1507,14 +1507,14 @@ mod tests {
assert_eq!(a.clone(), from_str(a.to_pretty_str()).unwrap());
}

fn with_str_writer(f: |@mut io::Writer|) -> ~str {
fn with_str_writer(f: |&mut io::Writer|) -> ~str {
use std::io::mem::MemWriter;
use std::io::Decorator;
use std::str;

let m = @mut MemWriter::new();
f(m as @mut io::Writer);
str::from_utf8(*m.inner_ref())
let mut m = MemWriter::new();
f(&mut m as &mut io::Writer);
str::from_utf8_owned(m.inner())
}

#[test]
Expand Down
5 changes: 3 additions & 2 deletions src/libextra/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -945,8 +945,9 @@ impl MetricMap {
/// Load MetricDiff from a file.
pub fn load(p: &Path) -> MetricMap {
assert!(p.exists());
let f = @mut File::open(p) as @mut io::Reader;
let mut decoder = json::Decoder::init(json::from_reader(f).unwrap());
let mut f = File::open(p);
let value = json::from_reader(&mut f as &mut io::Reader).unwrap();
let mut decoder = json::Decoder::init(value);
MetricMap(Decodable::decode(&mut decoder))
}

Expand Down
9 changes: 6 additions & 3 deletions src/librustdoc/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::init(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,
Expand Down
2 changes: 1 addition & 1 deletion src/libsyntax/parse/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,7 @@ mod test {
let mut writer = MemWriter::new();
let mut encoder = extra::json::Encoder::init(&mut writer as &mut io::Writer);
val.encode(&mut encoder);
str::from_utf8(*writer.inner_ref())
str::from_utf8_owned(writer.inner())
}

// produce a codemap::span
Expand Down

13 comments on commit a7b311a

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at erickt@a7b311a

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/json = a7b311a into auto

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/json = a7b311a merged ok, testing candidate = 3c3a5be4

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at erickt@a7b311a

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/json = a7b311a into auto

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/json = a7b311a merged ok, testing candidate = 56c82bc9

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

saw approval from huonw
at erickt@a7b311a

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

merging erickt/rust/json = a7b311a into auto

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

erickt/rust/json = a7b311a merged ok, testing candidate = 9bf62f7

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@bors
Copy link
Contributor

@bors bors commented on a7b311a Nov 30, 2013

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

fast-forwarding master to auto = 9bf62f7

Please sign in to comment.