diff --git a/benches/bench_log.rs b/benches/bench_log.rs index be2b4a53..91a4a885 100755 --- a/benches/bench_log.rs +++ b/benches/bench_log.rs @@ -8,9 +8,9 @@ extern crate serde; extern crate "rustc-serialize" as rustc_serialize; extern crate test; -use std::io::ByRefWriter; -use std::io::extensions::Bytes; -use std::io; +use std::old_io::ByRefWriter; +use std::old_io::extensions::Bytes; +use std::old_io; use std::num::FromPrimitive; use test::Bencher; @@ -620,7 +620,7 @@ impl MyMemWriter0 { impl Writer for MyMemWriter0 { #[inline] - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { self.buf.push_all(buf); Ok(()) } @@ -660,7 +660,7 @@ fn push_all_bytes(dst: &mut Vec, src: &[u8]) { impl Writer for MyMemWriter1 { #[inline] - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { push_all_bytes(&mut self.buf, buf); Ok(()) } @@ -761,7 +761,7 @@ fn bench_serializer_slice(b: &mut Bencher) { b.iter(|| { for item in buf.iter_mut(){ *item = 0; } - let mut wr = std::io::BufWriter::new(&mut buf); + let mut wr = std::old_io::BufWriter::new(&mut buf); let mut serializer = json::Serializer::new(wr.by_ref()); log.serialize(&mut serializer).unwrap(); diff --git a/serde2/benches/bench_log.rs b/serde2/benches/bench_log.rs index 4742a8fb..33b915f6 100644 --- a/serde2/benches/bench_log.rs +++ b/serde2/benches/bench_log.rs @@ -8,8 +8,8 @@ extern crate serde2; extern crate "rustc-serialize" as rustc_serialize; extern crate test; -use std::io; -use std::io::ByRefWriter; +use std::old_io; +use std::old_io::ByRefWriter; use std::num::FromPrimitive; use test::Bencher; @@ -928,7 +928,7 @@ impl MyMemWriter0 { impl Writer for MyMemWriter0 { #[inline] - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { self.buf.push_all(buf); Ok(()) } @@ -968,7 +968,7 @@ fn push_all_bytes(dst: &mut Vec, src: &[u8]) { impl Writer for MyMemWriter1 { #[inline] - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { push_all_bytes(&mut self.buf, buf); Ok(()) } @@ -1069,7 +1069,7 @@ fn bench_serializer_slice(b: &mut Bencher) { b.iter(|| { for item in buf.iter_mut(){ *item = 0; } - let mut wr = std::io::BufWriter::new(&mut buf); + let mut wr = std::old_io::BufWriter::new(&mut buf); let mut serializer = json::Writer::new(wr.by_ref()); serializer.visit(&log).unwrap(); diff --git a/serde2/src/json/error.rs b/serde2/src/json/error.rs index ddee5556..3af53a3e 100644 --- a/serde2/src/json/error.rs +++ b/serde2/src/json/error.rs @@ -1,6 +1,6 @@ use std::error; use std::fmt; -use std::io; +use std::old_io; use de; @@ -79,7 +79,7 @@ impl fmt::Debug for ErrorCode { pub enum Error { /// msg, line, col SyntaxError(ErrorCode, usize, usize), - IoError(io::IoError), + IoError(old_io::IoError), /* ExpectedError(String, String), MissingFieldError(String), @@ -121,8 +121,8 @@ impl error::Error for Error { } } -impl error::FromError for Error { - fn from_error(error: io::IoError) -> Error { +impl error::FromError for Error { + fn from_error(error: old_io::IoError) -> Error { Error::IoError(error) } } diff --git a/serde2/src/json/ser.rs b/serde2/src/json/ser.rs index 0749a42a..fe82204e 100644 --- a/serde2/src/json/ser.rs +++ b/serde2/src/json/ser.rs @@ -1,5 +1,5 @@ use std::f64; -use std::io::{self, ByRefWriter, IoError}; +use std::old_io::{self, ByRefWriter, IoError}; use std::num::{Float, FpCategory}; use std::string::FromUtf8Error; @@ -11,7 +11,7 @@ pub struct Writer { writer: W, } -impl Writer { +impl Writer { /// Creates a new JSON visitr whose output will be written to the writer /// specified. #[inline] @@ -28,7 +28,7 @@ impl Writer { } } -impl ser::Serializer for Writer { +impl ser::Serializer for Writer { type Value = (); type Error = IoError; @@ -44,7 +44,7 @@ struct Visitor<'a, W: 'a> { writer: &'a mut W, } -impl<'a, W: io::Writer> ser::Visitor for Visitor<'a, W> { +impl<'a, W: old_io::Writer> ser::Visitor for Visitor<'a, W> { type Value = (); type Error = IoError; @@ -188,7 +188,7 @@ impl<'a, W: io::Writer> ser::Visitor for Visitor<'a, W> { } #[inline] -pub fn escape_bytes(wr: &mut W, bytes: &[u8]) -> Result<(), IoError> { +pub fn escape_bytes(wr: &mut W, bytes: &[u8]) -> Result<(), IoError> { try!(wr.write_str("\"")); let mut start = 0; @@ -206,7 +206,7 @@ pub fn escape_bytes(wr: &mut W, bytes: &[u8]) -> Result<(), IoErr }; if start < i { - try!(wr.write(&bytes[start..i])); + try!(wr.write_all(&bytes[start..i])); } try!(wr.write_str(escaped)); @@ -215,34 +215,34 @@ pub fn escape_bytes(wr: &mut W, bytes: &[u8]) -> Result<(), IoErr } if start != bytes.len() { - try!(wr.write(&bytes[start..])); + try!(wr.write_all(&bytes[start..])); } wr.write_str("\"") } #[inline] -pub fn escape_str(wr: &mut W, value: &str) -> Result<(), IoError> { +pub fn escape_str(wr: &mut W, value: &str) -> Result<(), IoError> { escape_bytes(wr, value.as_bytes()) } #[inline] -pub fn escape_char(wr: &mut W, value: char) -> Result<(), IoError> { +pub fn escape_char(wr: &mut W, value: char) -> Result<(), IoError> { let mut buf = &mut [0; 4]; value.encode_utf8(buf); escape_bytes(wr, buf) } -fn fmt_f64_or_null(wr: &mut W, value: f64) -> Result<(), IoError> { +fn fmt_f64_or_null(wr: &mut W, value: f64) -> Result<(), IoError> { match value.classify() { FpCategory::Nan | FpCategory::Infinite => wr.write_str("null"), - _ => wr.write_str(f64::to_str_digits(value, 6).as_slice()), + _ => wr.write_str(&f64::to_str_digits(value, 6)), } } #[inline] pub fn to_writer(wr: &mut W, value: &T) -> Result<(), IoError> - where W: io::Writer, + where W: old_io::Writer, T: ser::Serialize, { let mut wr = Writer::new(wr.by_ref()); diff --git a/serde2/src/json/value.rs b/serde2/src/json/value.rs index 7a2d89af..c620c3b0 100644 --- a/serde2/src/json/value.rs +++ b/serde2/src/json/value.rs @@ -1,6 +1,6 @@ use std::collections::BTreeMap; use std::fmt; -use std::io; +use std::old_io; use std::str; use ser::{self, Serializer}; @@ -51,9 +51,9 @@ struct WriterFormatter<'a, 'b: 'a> { inner: &'a mut fmt::Formatter<'b>, } -impl<'a, 'b> io::Writer for WriterFormatter<'a, 'b> { - fn write(&mut self, buf: &[u8]) -> io::IoResult<()> { - self.inner.write_str(str::from_utf8(buf).unwrap()).map_err(|_| io::IoError::last_error()) +impl<'a, 'b> old_io::Writer for WriterFormatter<'a, 'b> { + fn write_all(&mut self, buf: &[u8]) -> old_io::IoResult<()> { + self.inner.write_str(str::from_utf8(buf).unwrap()).map_err(|_| old_io::IoError::last_error()) } } diff --git a/src/json/error.rs b/src/json/error.rs index b464c769..91cf4c95 100644 --- a/src/json/error.rs +++ b/src/json/error.rs @@ -1,6 +1,6 @@ use std::error; use std::fmt; -use std::io; +use std::old_io; use de::{Token, TokenKind}; @@ -82,7 +82,7 @@ impl fmt::Debug for ErrorCode { pub enum Error { /// msg, line, col SyntaxError(ErrorCode, usize, usize), - IoError(io::IoError), + IoError(old_io::IoError), ExpectedError(String, String), MissingFieldError(String), UnknownVariantError(String), @@ -118,8 +118,8 @@ impl error::Error for Error { } } -impl error::FromError for Error { - fn from_error(error: io::IoError) -> Error { +impl error::FromError for Error { + fn from_error(error: old_io::IoError) -> Error { Error::IoError(error) } } diff --git a/src/json/mod.rs b/src/json/mod.rs index ad5fa3e1..629dcff5 100644 --- a/src/json/mod.rs +++ b/src/json/mod.rs @@ -65,7 +65,7 @@ To serialize using `Serialize`: extern crate serde_macros; extern crate serde; -use std::io::ByRefWriter; +use std::old_io::ByRefWriter; use serde::json; use serde::Serialize; @@ -319,7 +319,7 @@ pub mod error; #[cfg(test)] mod tests { use std::fmt::Debug; - use std::io; + use std::old_io; use std::str; use std::string; use std::collections::BTreeMap; @@ -425,7 +425,7 @@ mod tests { } fn test_encode_ok< - T: PartialEq + Debug + ToJson + ser::Serialize>, io::IoError> + T: PartialEq + Debug + ToJson + ser::Serialize>, old_io::IoError> >(errors: &[(T, &str)]) { for &(ref value, out) in errors.iter() { let out = out.to_string(); diff --git a/src/json/ser.rs b/src/json/ser.rs index 7d7b0f5a..3cd9192f 100644 --- a/src/json/ser.rs +++ b/src/json/ser.rs @@ -1,7 +1,7 @@ use std::f32; use std::f64; use std::num::{Float, FpCategory}; -use std::io::{IoError, IoResult}; +use std::old_io::{IoError, IoResult}; use std::string::FromUtf8Error; use ser::Serialize; @@ -25,7 +25,7 @@ fn escape_bytes(wr: &mut W, bytes: &[u8]) -> IoResult<()> { }; if start < i { - try!(wr.write(&bytes[start..i])); + try!(wr.write_all(&bytes[start..i])); } try!(wr.write_str(escaped)); @@ -34,7 +34,7 @@ fn escape_bytes(wr: &mut W, bytes: &[u8]) -> IoResult<()> { } if start != bytes.len() { - try!(wr.write(&bytes[start..])); + try!(wr.write_all(&bytes[start..])); } wr.write_str("\"") @@ -69,12 +69,12 @@ fn spaces(wr: &mut W, mut n: usize) -> IoResult<()> { const BUF: &'static [u8; LEN] = &[b' '; LEN]; while n >= LEN { - try!(wr.write(BUF)); + try!(wr.write_all(BUF)); n -= LEN; } if n > 0 { - wr.write(&BUF[..n]) + wr.write_all(&BUF[..n]) } else { Ok(()) } diff --git a/src/json/value.rs b/src/json/value.rs index 41221daa..01052a39 100644 --- a/src/json/value.rs +++ b/src/json/value.rs @@ -1,7 +1,7 @@ use std::collections::{HashMap, BTreeMap, btree_map}; use std::fmt; -use std::io::{ByRefWriter, IoResult}; -use std::io; +use std::old_io::{ByRefWriter, IoResult}; +use std::old_io; use std::str; use std::string::ToString; use std::vec; @@ -221,8 +221,8 @@ struct WriterFormatter<'a, 'b: 'a> { } impl<'a, 'b> Writer for WriterFormatter<'a, 'b> { - fn write(&mut self, buf: &[u8]) -> IoResult<()> { - self.inner.write_str(str::from_utf8(buf).unwrap()).map_err(|_| io::IoError::last_error()) + fn write_all(&mut self, buf: &[u8]) -> IoResult<()> { + self.inner.write_str(str::from_utf8(buf).unwrap()).map_err(|_| old_io::IoError::last_error()) } }