Repository: BurntSushi/rust-csv (language: rust)

Issue:
method `detail` is not a member of trait `StdError`
Just upgraded my nightly rust to the `2015-1-23` build, and now running into compilation errors on one of my projects:

```
   Compiling csv v0.12.9
/Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.12.9/src/lib.rs:317:5: 317:66 error: method `detail` is not a member of trait `StdError`
/Users/me/.cargo/registry/src/github.com-1ecc6299db9ec823/csv-0.12.9/src/lib.rs:317     fn detail(&self) -> Option<String> { Some(self.to_string()) }
                                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
error: aborting due to previous error
Could not compile `csv`.
```

This sounds like it's related to https://github.com/rust-lang/rust/commit/3cb9fa26ef9905c00a29ea577fb55a12a91c8e7b . I tried just deleting the `detail` method indicated by the error message (since `cause` was already implemented, and the RFC made it sound like that's what it turned into), but that led to another problem that I didn't understand. So I gave up.

But here's an issue, anyway.



Discussion / hints:
No worries! I'll fix this tonight. Thank you for the report. :-)

Possible to get a faster fix? I was using this for a project.

Not from me. I'm at work.

If you really need something working, I'd suggest moving back to an older version of Rust nightly.

@BurntSushi problem is rustc-serialize was updated. I'll send you a PR in a minute fixing this.

@alexchandel Thanks. :-) If I get a PR that passes tests, I can update `crates.io`.

(N.B. You can set your `Cargo.toml` to use an older version of `rustc-serialize`.)

Want me to bump the VN?

No thanks. I have a `cargo-up` script that handles all that nonsense. :-)


Fix patch:
diff --git a/src/bench.rs b/src/bench.rs
index 54e8ad1b..eed611e8 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<T, E: Show>(r: Result<T, E>) -> T {
+fn ordie<T, E: Debug+Display>(r: Result<T, E>) -> T {
     r.or_else(|e: E| -> Result<T, E> panic!(format!("{:?}", e))).unwrap()
 }
 
diff --git a/src/encoder.rs b/src/encoder.rs
index d98b169c..5ed0b0b8 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<F>(&mut self, _: usize, _: F) -> CsvResult<()>
-                       where F: FnMut(&mut Encoded) -> CsvResult<()> {
+                       where F: FnOnce(&mut Encoded) -> CsvResult<()> {
         unimplemented!()
     }
     fn emit_map_elt_val<F>(&mut self, _: usize, _: F) -> CsvResult<()>
diff --git a/src/lib.rs b/src/lib.rs
index e6057e43..45aad5f3 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<String> { Some(self.to_string()) }
+    // fn detail(&self) -> Option<String> { Some(self.to_string()) }
 
     fn cause(&self) -> Option<&StdError> {
         match *self {
diff --git a/src/writer.rs b/src/writer.rs
index 16e363f2..d4df765a 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -431,7 +431,7 @@ impl<W: io::Writer> Writer<W> {
                     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<W: io::Writer> Writer<W> {
                         buf.push(self.escape);
                         buf.push(self.quote);
                     }
-                    s = s.slice_from(next_quote + 1);
+                    s = &s[next_quote + 1..];
                 }
             }
         }


Test patch:
diff --git a/src/bytestr.rs b/src/bytestr.rs
index 470a9c01..ca7d9f07 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: