Skip to content

Commit

Permalink
rustup
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed Mar 26, 2015
1 parent 04f2347 commit 382f071
Show file tree
Hide file tree
Showing 11 changed files with 24 additions and 23 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ Don't like tuples? That's fine. Use a struct instead:

```rust
extern crate csv;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;

#[derive(RustcDecodable)]
struct Record {
Expand Down
2 changes: 1 addition & 1 deletion examples/nfl_plays.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate csv;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;

#[allow(dead_code)]
#[derive(RustcDecodable)]
Expand Down
2 changes: 1 addition & 1 deletion examples/rational_numbers.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

extern crate csv;
extern crate regex;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;

use std::str;

Expand Down
2 changes: 1 addition & 1 deletion examples/simple_missing.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate csv;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;

#[derive(RustcDecodable)]
struct Record {
Expand Down
2 changes: 1 addition & 1 deletion examples/simple_struct.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
extern crate csv;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;

#[derive(RustcDecodable)]
struct Record {
Expand Down
8 changes: 4 additions & 4 deletions src/bytestr.rs
Original file line number Diff line number Diff line change
Expand Up @@ -132,31 +132,31 @@ impl ops::Deref for ByteString {
impl ops::Index<ops::RangeFull> for ByteString {
type Output = [u8];

fn index<'a>(&'a self, _: &ops::RangeFull) -> &'a [u8] {
fn index<'a>(&'a self, _: ops::RangeFull) -> &'a [u8] {
&**self
}
}

impl ops::Index<ops::RangeFrom<usize>> for ByteString {
type Output = [u8];

fn index<'a>(&'a self, index: &ops::RangeFrom<usize>) -> &'a [u8] {
fn index<'a>(&'a self, index: ops::RangeFrom<usize>) -> &'a [u8] {
&(&**self)[index.start..]
}
}

impl ops::Index<ops::RangeTo<usize>> for ByteString {
type Output = [u8];

fn index<'a>(&'a self, index: &ops::RangeTo<usize>) -> &'a [u8] {
fn index<'a>(&'a self, index: ops::RangeTo<usize>) -> &'a [u8] {
&(&**self)[..index.end]
}
}

impl ops::Index<ops::Range<usize>> for ByteString {
type Output = [u8];

fn index<'a>(&'a self, index: &ops::Range<usize>) -> &'a [u8] {
fn index<'a>(&'a self, index: ops::Range<usize>) -> &'a [u8] {
&(&**self)[index.start..index.end]
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/encoder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ impl serialize::Encoder for Encoded {
}
fn emit_char(&mut self, v: char) -> Result<()> {
let mut bytes = [0u8; 4];
let n = v.encode_utf8(bytes.as_mut_slice()).unwrap_or(0);
let n = v.encode_utf8(&mut bytes).unwrap_or(0);
self.push_bytes(&bytes[..n])
}
fn emit_str(&mut self, v: &str) -> Result<()> {
Expand Down
4 changes: 2 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -179,10 +179,10 @@
#![deny(missing_docs)]

#![cfg_attr(test, feature(test))]
#![feature(core, io, std_misc, unicode)]
#![feature(convert, core, io, into_cow, std_misc, unicode)]

extern crate byteorder;
extern crate "rustc-serialize" as rustc_serialize;
extern crate rustc_serialize;
#[cfg(test)] extern crate test;

use std::error::Error as StdError;
Expand Down
10 changes: 5 additions & 5 deletions src/reader.rs
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
use std::borrow::IntoCow;
use std::fs;
use std::io::{self, BufRead};
use std::path::AsPath;
use std::path::Path;

use rustc_serialize::Decodable;

Expand Down Expand Up @@ -166,7 +166,7 @@ impl<R: io::Read> Reader<R> {

impl Reader<fs::File> {
/// Creates a new CSV reader for the data at the file path given.
pub fn from_file<P: AsPath>(path: P) -> Result<Reader<fs::File>> {
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Reader<fs::File>> {
Ok(Reader::from_reader(try!(fs::File::open(path))))
}
}
Expand Down Expand Up @@ -205,7 +205,7 @@ impl<R: io::Read> Reader<R> {
/// currently, the *names* of the struct members are irrelevant.)
///
/// ```rust
/// extern crate "rustc-serialize" as rustc_serialize;
/// extern crate rustc_serialize;
/// # extern crate csv;
/// # fn main() {
///
Expand All @@ -231,7 +231,7 @@ impl<R: io::Read> Reader<R> {
/// valid data in every record (whether it be empty or malformed).
///
/// ```rust
/// extern crate "rustc-serialize" as rustc_serialize;
/// extern crate rustc_serialize;
/// # extern crate csv;
/// # fn main() {
///
Expand Down Expand Up @@ -264,7 +264,7 @@ impl<R: io::Read> Reader<R> {
/// "tail" of another tuple/struct/`Vec` to capture all remaining fields:
///
/// ```rust
/// extern crate "rustc-serialize" as rustc_serialize;
/// extern crate rustc_serialize;
/// # extern crate csv;
/// # fn main() {
///
Expand Down
7 changes: 4 additions & 3 deletions src/tests.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,15 @@ use {
RecordTerminator, QuoteStyle,
};

fn assert_svec_eq<S: Str, T: Str>(got: Vec<Vec<S>>, expected: Vec<Vec<T>>) {
fn assert_svec_eq<S, T>(got: Vec<Vec<S>>, expected: Vec<Vec<T>>)
where S: AsRef<str>, T: AsRef<str> {
let got: Vec<Vec<&str>> =
got.iter().map(|row| {
row.iter().map(|f| f.as_slice()).collect()
row.iter().map(|f| f.as_ref()).collect()
}).collect();
let expected: Vec<Vec<&str>> =
expected.iter().map(|row| {
row.iter().map(|f| f.as_slice()).collect()
row.iter().map(|f| f.as_ref()).collect()
}).collect();

println!("got len: {}, expected len: {}", got.len(), expected.len());
Expand Down
6 changes: 3 additions & 3 deletions src/writer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ use std::borrow::IntoCow;
use std::error::FromError;
use std::fs;
use std::io::{self, Write};
use std::path::AsPath;
use std::path::Path;
use std::str;

use rustc_serialize::Encodable;
Expand Down Expand Up @@ -83,7 +83,7 @@ impl Writer<fs::File> {
///
/// The file is created if it does not already exist and is truncated
/// otherwise.
pub fn from_file<P: AsPath>(path: P) -> Result<Writer<fs::File>> {
pub fn from_file<P: AsRef<Path>>(path: P) -> Result<Writer<fs::File>> {
Ok(Writer::from_writer(try!(fs::File::create(path))))
}
}
Expand Down Expand Up @@ -163,7 +163,7 @@ impl<W: io::Write> Writer<W> {
/// edit distances computed.
///
/// ```rust
/// extern crate "rustc-serialize" as rustc_serialize;
/// extern crate rustc_serialize;
/// # extern crate csv;
/// # fn main() {
///
Expand Down

0 comments on commit 382f071

Please sign in to comment.