Merge pull request #18 from csherratt/master

Update to latest nightly.
This commit is contained in:
Ty 2015-01-24 16:45:25 -08:00
commit 32f772328e
3 changed files with 24 additions and 14 deletions

View File

@ -13,7 +13,7 @@ pub struct InvalidEncoding {
detail: Option<String>,
}
impl fmt::String for InvalidEncoding {
impl fmt::Display for InvalidEncoding {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
InvalidEncoding { detail: None, desc } =>
@ -43,7 +43,7 @@ pub enum DecodingError {
SizeLimit
}
impl fmt::String for DecodingError {
impl fmt::Display for DecodingError {
fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result {
match *self {
DecodingError::IoError(ref ioerr) =>
@ -71,10 +71,10 @@ impl Error for DecodingError {
}
}
fn detail(&self) -> Option<String> {
fn cause(&self) -> Option<&Error> {
match *self {
DecodingError::IoError(ref err) => err.detail(),
DecodingError::InvalidEncoding(ref ib) => ib.detail.clone(),
DecodingError::IoError(ref err) => err.cause(),
DecodingError::InvalidEncoding(_) => None,
DecodingError::SizeLimit => None
}
}

View File

@ -1,6 +1,6 @@
extern crate "rustc-serialize" as serialize;
use std::fmt::Show;
use std::fmt::Debug;
use std::collections::HashMap;
use rustc_serialize::{
@ -20,7 +20,7 @@ use super::{
};
use super::SizeLimit::{Infinite, Bounded};
fn the_same<'a, V>(element: V) where V: Encodable, V: Decodable, V: PartialEq, V: Show {
fn the_same<'a, V>(element: V) where V: Encodable, V: Decodable, V: PartialEq, V: Debug {
assert!(element == decode(encode(&element, Infinite).unwrap().as_slice()).unwrap());
}

View File

@ -1,6 +1,7 @@
use std::io::{Writer, IoError};
use std::error::Error;
use std::num::Int;
use std::fmt;
use rustc_serialize::Encoder;
@ -10,7 +11,7 @@ pub type EncodingResult<T> = Result<T, EncodingError>;
/// An error that can be produced during encoding.
#[derive(Show)]
#[derive(Debug)]
pub enum EncodingError {
/// An error originating from the underlying `Writer`.
IoError(IoError),
@ -39,6 +40,15 @@ fn wrap_io(err: IoError) -> EncodingError {
EncodingError::IoError(err)
}
impl fmt::Display for EncodingError {
fn fmt(&self, f: &mut fmt::Formatter) -> Result<(), fmt::Error> {
match *self {
EncodingError::IoError(ref err) => write!(f, "IoError: {}", err),
EncodingError::SizeLimit => write!(f, "SizeLimit")
}
}
}
impl Error for EncodingError {
fn description(&self) -> &str {
match *self {
@ -47,9 +57,9 @@ impl Error for EncodingError {
}
}
fn detail(&self) -> Option<String> {
fn cause(&self) -> Option<&Error> {
match *self {
EncodingError::IoError(ref err) => err.detail(),
EncodingError::IoError(ref err) => err.cause(),
EncodingError::SizeLimit => None
}
}
@ -221,8 +231,8 @@ impl<'a, W: Writer> Encoder for EncoderWriter<'a, W> {
try!(self.emit_usize(len));
f(self)
}
fn emit_map_elt_key<F>(&mut self, _: usize, mut f: F) -> EncodingResult<()> where
F: FnMut(&mut EncoderWriter<'a, W>) -> EncodingResult<()> {
fn emit_map_elt_key<F>(&mut self, _: usize, f: F) -> EncodingResult<()> where
F: FnOnce(&mut EncoderWriter<'a, W>) -> EncodingResult<()> {
f(self)
}
fn emit_map_elt_val<F>(&mut self, _: usize, f: F) -> EncodingResult<()> where
@ -361,8 +371,8 @@ impl Encoder for SizeChecker {
try!(self.emit_usize(len));
f(self)
}
fn emit_map_elt_key<F>(&mut self, _: usize, mut f: F) -> EncodingResult<()> where
F: FnMut(&mut SizeChecker) -> EncodingResult<()> {
fn emit_map_elt_key<F>(&mut self, _: usize, f: F) -> EncodingResult<()> where
F: FnOnce(&mut SizeChecker) -> EncodingResult<()> {
f(self)
}
fn emit_map_elt_val<F>(&mut self, _: usize, f: F) -> EncodingResult<()> where