update for rustc
This commit is contained in:
parent
6bc25f21db
commit
e5d0c33acd
|
|
@ -3,7 +3,7 @@
|
|||
#![crate_type = "dylib"]
|
||||
|
||||
#![doc(html_logo_url = "./icon.png")]
|
||||
#![feature(core, io, unicode)]
|
||||
#![feature(core, unicode)]
|
||||
|
||||
extern crate rustc_serialize;
|
||||
extern crate byteorder;
|
||||
|
|
|
|||
|
|
@ -2,8 +2,9 @@ use std::io::Read;
|
|||
use std::io::Error as IoError;
|
||||
use std::io::Result as IoResult;
|
||||
use std::num::{cast, NumCast};
|
||||
use std::error::{Error, FromError};
|
||||
use std::error::Error;
|
||||
use std::fmt;
|
||||
use std::convert::From;
|
||||
|
||||
use rustc_serialize::Decoder;
|
||||
|
||||
|
|
@ -35,7 +36,7 @@ impl fmt::Display for InvalidEncoding {
|
|||
///
|
||||
/// If decoding from a Buffer, assume that the buffer has been left
|
||||
/// in an invalid state.
|
||||
#[derive(Eq, PartialEq, Clone, Debug)]
|
||||
#[derive(Debug)]
|
||||
pub enum DecodingError {
|
||||
/// If the error stems from the reader that is being used
|
||||
/// during decoding, that error will be stored and returned here.
|
||||
|
|
@ -94,8 +95,8 @@ impl Error for DecodingError {
|
|||
}
|
||||
}
|
||||
|
||||
impl FromError<IoError> for DecodingError {
|
||||
fn from_error(err: IoError) -> DecodingError {
|
||||
impl From<IoError> for DecodingError {
|
||||
fn from(err: IoError) -> DecodingError {
|
||||
DecodingError::IoError(err)
|
||||
}
|
||||
}
|
||||
|
|
@ -357,7 +358,7 @@ fn read_at_least<R: Read>(reader: &mut R, min: usize, buf: &mut [u8]) -> IoResul
|
|||
use std::io::ErrorKind;
|
||||
if min > buf.len() {
|
||||
return Err(IoError::new(
|
||||
ErrorKind::InvalidInput, "the buffer is too short", None));
|
||||
ErrorKind::InvalidInput, "the buffer is too short"));
|
||||
}
|
||||
|
||||
let mut read = 0;
|
||||
|
|
@ -369,8 +370,7 @@ fn read_at_least<R: Read>(reader: &mut R, min: usize, buf: &mut [u8]) -> IoResul
|
|||
zeroes += 1;
|
||||
if zeroes >= 1000 {
|
||||
return Err(IoError::new(ErrorKind::Other,
|
||||
"no progress was made",
|
||||
None ));
|
||||
"no progress was made"));
|
||||
}
|
||||
}
|
||||
Ok(n) => {
|
||||
|
|
@ -401,7 +401,7 @@ unsafe fn slice_vec_capacity<'a, T>(v: &'a mut Vec<T>, start: usize, end: usize)
|
|||
fn push_at_least<R: Read>(reader: &mut R, min: usize, len: usize, buf: &mut Vec<u8>) -> IoResult<usize> {
|
||||
use std::io::ErrorKind;
|
||||
if min > len {
|
||||
return Err(IoError::new(ErrorKind::InvalidInput, "the buffer is too short", None));
|
||||
return Err(IoError::new(ErrorKind::InvalidInput, "the buffer is too short"));
|
||||
}
|
||||
|
||||
let start_len = buf.len();
|
||||
|
|
|
|||
|
|
@ -230,7 +230,8 @@ fn too_big_char_decode() {
|
|||
let encoded = vec![0x41];
|
||||
let mut encoded_ref = &encoded[..];
|
||||
let decoded: Result<char, _> = decode_from(&mut encoded_ref, Bounded(1));
|
||||
assert_eq!(decoded, Ok('A'));
|
||||
assert!(decoded.is_ok());
|
||||
assert_eq!(decoded.unwrap(), 'A');
|
||||
}
|
||||
|
||||
#[test]
|
||||
|
|
|
|||
|
|
@ -2,7 +2,6 @@ use std::io::Write;
|
|||
use std::io::Error as IoError;
|
||||
use std::io::ErrorKind as IoErrorKind;
|
||||
use std::error::Error;
|
||||
use std::num::Int;
|
||||
use std::fmt;
|
||||
|
||||
use rustc_serialize::Encoder;
|
||||
|
|
@ -14,7 +13,7 @@ pub type EncodingResult<T> = Result<T, EncodingError>;
|
|||
|
||||
|
||||
/// An error that can be produced during encoding.
|
||||
#[derive(Debug,Clone,PartialEq)]
|
||||
#[derive(Debug)]
|
||||
pub enum EncodingError {
|
||||
/// An error originating from the underlying `Writer`.
|
||||
IoError(IoError),
|
||||
|
|
@ -43,8 +42,7 @@ fn wrap_io(err: ByteOrderError) -> EncodingError {
|
|||
ByteOrderError::Io(ioe) => EncodingError::IoError(ioe),
|
||||
ByteOrderError::UnexpectedEOF => EncodingError::IoError(
|
||||
IoError::new(IoErrorKind::Other,
|
||||
"ByteOrder could not write to the buffer",
|
||||
None))
|
||||
"ByteOrder could not write to the buffer"))
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -166,7 +164,7 @@ impl<'a, W: Write> Encoder for EncoderWriter<'a, W> {
|
|||
_: usize,
|
||||
f: F) -> EncodingResult<()> where
|
||||
F: FnOnce(&mut EncoderWriter<'a, W>) -> EncodingResult<()> {
|
||||
let max_u32: u32 = Int::max_value();
|
||||
let max_u32: u32 = ::std::u32::MAX;
|
||||
if v_id > (max_u32 as usize) {
|
||||
panic!("Variant tag doesn't fit in a u32")
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue