From 9fbf2061a73c2f667111b23024a228aa97409d7a Mon Sep 17 00:00:00 2001 From: Alex Chandel Date: Fri, 23 Jan 2015 10:47:00 -0600 Subject: [PATCH] Fix build for Show/String->Debug/Display. --- src/bench.rs | 4 ++-- src/bytestr.rs | 2 +- src/encoder.rs | 4 ++-- src/lib.rs | 8 ++++---- src/writer.rs | 4 ++-- 5 files changed, 11 insertions(+), 11 deletions(-) diff --git a/src/bench.rs b/src/bench.rs index 54e8ad1..eed611e 100644 --- a/src/bench.rs +++ b/src/bench.rs @@ -1,4 +1,4 @@ -use std::fmt::Show; +use std::fmt::{Debug, Display}; use std::io::{self, ByRefReader}; use std::io::Reader as IoReader; use stdtest::Bencher; @@ -7,7 +7,7 @@ use Reader; static CSV_DATA: &'static str = "./examples/data/bench.csv"; -fn ordie(r: Result) -> T { +fn ordie(r: Result) -> T { r.or_else(|e: E| -> Result panic!(format!("{:?}", e))).unwrap() } diff --git a/src/bytestr.rs b/src/bytestr.rs index 470a9c0..ca7d9f0 100644 --- a/src/bytestr.rs +++ b/src/bytestr.rs @@ -148,7 +148,7 @@ impl ByteString { } } -impl fmt::Show for ByteString { +impl fmt::Debug for ByteString { /// Writes the underlying bytes as a `&[u8]`. fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { // XXX: Ideally, we could just do this: diff --git a/src/encoder.rs b/src/encoder.rs index d98b169..5ed0b0b 100644 --- a/src/encoder.rs +++ b/src/encoder.rs @@ -67,7 +67,7 @@ impl serialize::Encoder for Encoded { fn emit_char(&mut self, v: char) -> CsvResult<()> { let mut bytes = [0u8; 4]; let n = v.encode_utf8(bytes.as_mut_slice()).unwrap_or(0); - self.push_bytes(bytes.slice_to(n)) + self.push_bytes(&bytes[..n]) } fn emit_str(&mut self, v: &str) -> CsvResult<()> { self.push_string(v) @@ -153,7 +153,7 @@ impl serialize::Encoder for Encoded { unimplemented!() } fn emit_map_elt_key(&mut self, _: usize, _: F) -> CsvResult<()> - where F: FnMut(&mut Encoded) -> CsvResult<()> { + where F: FnOnce(&mut Encoded) -> CsvResult<()> { unimplemented!() } fn emit_map_elt_val(&mut self, _: usize, _: F) -> CsvResult<()> diff --git a/src/lib.rs b/src/lib.rs index e6057e4..45aad5f 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -272,7 +272,7 @@ pub enum ParseErrorKind { InvalidUTF8, } -impl fmt::String for Error { +impl fmt::Display for Error { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { Error::Encode(ref msg) => write!(f, "CSV encode error: {}", msg), @@ -284,14 +284,14 @@ impl fmt::String for Error { } } -impl fmt::String for ParseError { +impl fmt::Display for ParseError { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "CSV parse error:{}:{}: {}", self.line, self.column, self.kind) } } -impl fmt::String for ParseErrorKind { +impl fmt::Display for ParseErrorKind { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { match *self { ParseErrorKind::UnequalLengths(first, cur) => @@ -314,7 +314,7 @@ impl StdError for Error { } } - fn detail(&self) -> Option { Some(self.to_string()) } + // fn detail(&self) -> Option { Some(self.to_string()) } fn cause(&self) -> Option<&StdError> { match *self { diff --git a/src/writer.rs b/src/writer.rs index 16e363f..d4df765 100644 --- a/src/writer.rs +++ b/src/writer.rs @@ -431,7 +431,7 @@ impl Writer { break } Some(next_quote) => { - buf.push_all(s.slice_to(next_quote)); + buf.push_all(&s[..next_quote]); if self.double_quote { buf.push(self.quote); buf.push(self.quote); @@ -439,7 +439,7 @@ impl Writer { buf.push(self.escape); buf.push(self.quote); } - s = s.slice_from(next_quote + 1); + s = &s[next_quote + 1..]; } } }