Follow rust std: The old io module is now called old_io

This commit is contained in:
Thomas Bahn 2015-02-06 15:26:06 +01:00
parent 9a284ae7c2
commit 5782657502
9 changed files with 47 additions and 47 deletions

View File

@ -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<u8>, 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();

View File

@ -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<u8>, 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();

View File

@ -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<io::IoError> for Error {
fn from_error(error: io::IoError) -> Error {
impl error::FromError<old_io::IoError> for Error {
fn from_error(error: old_io::IoError) -> Error {
Error::IoError(error)
}
}

View File

@ -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<W> {
writer: W,
}
impl<W: io::Writer> Writer<W> {
impl<W: old_io::Writer> Writer<W> {
/// Creates a new JSON visitr whose output will be written to the writer
/// specified.
#[inline]
@ -28,7 +28,7 @@ impl<W: io::Writer> Writer<W> {
}
}
impl<W: io::Writer> ser::Serializer for Writer<W> {
impl<W: old_io::Writer> ser::Serializer for Writer<W> {
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<W: io::Writer>(wr: &mut W, bytes: &[u8]) -> Result<(), IoError> {
pub fn escape_bytes<W: old_io::Writer>(wr: &mut W, bytes: &[u8]) -> Result<(), IoError> {
try!(wr.write_str("\""));
let mut start = 0;
@ -206,7 +206,7 @@ pub fn escape_bytes<W: io::Writer>(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<W: io::Writer>(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<W: io::Writer>(wr: &mut W, value: &str) -> Result<(), IoError> {
pub fn escape_str<W: old_io::Writer>(wr: &mut W, value: &str) -> Result<(), IoError> {
escape_bytes(wr, value.as_bytes())
}
#[inline]
pub fn escape_char<W: io::Writer>(wr: &mut W, value: char) -> Result<(), IoError> {
pub fn escape_char<W: old_io::Writer>(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<W: io::Writer>(wr: &mut W, value: f64) -> Result<(), IoError> {
fn fmt_f64_or_null<W: old_io::Writer>(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<W, T>(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());

View File

@ -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())
}
}

View File

@ -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<io::IoError> for Error {
fn from_error(error: io::IoError) -> Error {
impl error::FromError<old_io::IoError> for Error {
fn from_error(error: old_io::IoError) -> Error {
Error::IoError(error)
}
}

View File

@ -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<super::Serializer<Vec<u8>>, io::IoError>
T: PartialEq + Debug + ToJson + ser::Serialize<super::Serializer<Vec<u8>>, old_io::IoError>
>(errors: &[(T, &str)]) {
for &(ref value, out) in errors.iter() {
let out = out.to_string();

View File

@ -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<W: Writer>(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<W: Writer>(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<W: Writer>(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(())
}

View File

@ -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())
}
}