Skip to content
This repository was archived by the owner on Dec 1, 2023. It is now read-only.

Commit d0fd70a

Browse files
committed
Switch std::fmt::{Writer to Write} for compatibility with latest Rustc (6c065fc8c) (rust-lang/rust@bc9084b)
1 parent d790168 commit d0fd70a

File tree

1 file changed

+8
-9
lines changed

1 file changed

+8
-9
lines changed

src/json.rs

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -422,7 +422,7 @@ impl std::error::FromError<fmt::Error> for EncoderError {
422422
pub type EncodeResult<T> = Result<T, EncoderError>;
423423
pub type DecodeResult<T> = Result<T, DecoderError>;
424424

425-
fn escape_str(wr: &mut fmt::Writer, v: &str) -> EncodeResult<()> {
425+
fn escape_str(wr: &mut fmt::Write, v: &str) -> EncodeResult<()> {
426426
try!(wr.write_str("\""));
427427

428428
let mut start = 0;
@@ -484,14 +484,14 @@ fn escape_str(wr: &mut fmt::Writer, v: &str) -> EncodeResult<()> {
484484
Ok(())
485485
}
486486

487-
fn escape_char(writer: &mut fmt::Writer, v: char) -> EncodeResult<()> {
487+
fn escape_char(writer: &mut fmt::Write, v: char) -> EncodeResult<()> {
488488
let mut buf = [0; 4];
489489
let n = v.encode_utf8(&mut buf).unwrap();
490490
let buf = unsafe { str::from_utf8_unchecked(&buf[..n]) };
491491
escape_str(writer, buf)
492492
}
493493

494-
fn spaces(wr: &mut fmt::Writer, n: u32) -> EncodeResult<()> {
494+
fn spaces(wr: &mut fmt::Write, n: u32) -> EncodeResult<()> {
495495
let mut n = n as usize;
496496
const BUF: &'static str = " ";
497497

@@ -538,15 +538,15 @@ enum EncodingFormat {
538538

539539
/// A structure for implementing serialization to JSON.
540540
pub struct Encoder<'a> {
541-
writer: &'a mut (fmt::Writer+'a),
541+
writer: &'a mut (fmt::Write+'a),
542542
format : EncodingFormat,
543543
is_emitting_map_key: bool,
544544
}
545545

546546
impl<'a> Encoder<'a> {
547547
/// Creates a new encoder whose output will be written in human-readable
548548
/// JSON to the specified writer
549-
pub fn new_pretty(writer: &'a mut fmt::Writer) -> Encoder<'a> {
549+
pub fn new_pretty(writer: &'a mut fmt::Write) -> Encoder<'a> {
550550
Encoder {
551551
writer: writer,
552552
format: EncodingFormat::Pretty {
@@ -559,7 +559,7 @@ impl<'a> Encoder<'a> {
559559

560560
/// Creates a new encoder whose output will be written in compact
561561
/// JSON to the specified writer
562-
pub fn new(writer: &'a mut fmt::Writer) -> Encoder<'a> {
562+
pub fn new(writer: &'a mut fmt::Write) -> Encoder<'a> {
563563
Encoder {
564564
writer: writer,
565565
format: EncodingFormat::Compact,
@@ -2432,7 +2432,7 @@ struct FormatShim<'a, 'b: 'a> {
24322432
inner: &'a mut fmt::Formatter<'b>,
24332433
}
24342434

2435-
impl<'a, 'b> fmt::Writer for FormatShim<'a, 'b> {
2435+
impl<'a, 'b> fmt::Write for FormatShim<'a, 'b> {
24362436
fn write_str(&mut self, s: &str) -> fmt::Result {
24372437
match self.inner.write_str(s) {
24382438
Ok(_) => Ok(()),
@@ -3830,15 +3830,14 @@ mod tests {
38303830

38313831
#[test]
38323832
fn test_encode_hashmap_with_arbitrary_key() {
3833-
use std::old_io::Writer;
38343833
use std::collections::HashMap;
38353834
use std::fmt;
38363835
#[derive(PartialEq, Eq, Hash, RustcEncodable)]
38373836
struct ArbitraryType(u32);
38383837
let mut hm: HashMap<ArbitraryType, bool> = HashMap::new();
38393838
hm.insert(ArbitraryType(1), true);
38403839
let mut mem_buf = string::String::new();
3841-
let mut encoder = Encoder::new(&mut mem_buf as &mut fmt::Writer);
3840+
let mut encoder = Encoder::new(&mut mem_buf as &mut fmt::Write);
38423841
let result = hm.encode(&mut encoder);
38433842
match result.err().unwrap() {
38443843
EncoderError::BadHashmapKey => (),

0 commit comments

Comments
 (0)