commit_hash stringlengths 40 40 | author stringlengths 1 57 | date timestamp[s]date 2010-07-26 04:45:09 2026-04-14 18:21:10 | message stringlengths 8 1.39M | diff stringlengths 68 51.2k | files_changed int64 1 136 | insertions int64 0 2.35k | deletions int64 0 1.9k |
|---|---|---|---|---|---|---|---|
41ab4a8316275d9726199e337575aca804739408 | Evin Robertson | 2017-06-10T19:29:59 | Change transition_nfa to return an NfaInputAction enum instead of a pair of booleans. Only 3 of the 4 possibilities were allowed, enforced by documentation and an assert. Now perhaps slightly clearer what each state transition is doing. | diff --git a/csv-core/src/reader.rs b/csv-core/src/reader.rs
index 16cd4be..d6a76d7 100644
--- a/csv-core/src/reader.rs
+++ b/csv-core/src/reader.rs
@@ -382,6 +382,19 @@ pub enum ReadRecordNoCopyResult {
End,
}
+/// What should be done with input bytes during an NFA transition
+#[derive(Clone, Debug, Eq, Partia... | 1 | 75 | 63 |
34e957e63bb92853ba32c314f613d948e8a3c012 | Andrew Gallant | 2017-05-25T02:33:57 | csv/error: box the error.
The error type appears to have grown quite large and can result in lots of
byte copying. It's not clear exactly how much it costs, but boxing the
error results in less work.
Since we keep the box a secret, this adds a new ErrorKind that can be
extracted from a Error if one wants to do case a... | diff --git a/src/deserializer.rs b/src/deserializer.rs
index c24d903..5f1e3ef 100644
--- a/src/deserializer.rs
+++ b/src/deserializer.rs
@@ -12,7 +12,7 @@ use serde::de::{
use serde::de::value::BorrowedBytesDeserializer;
use byte_record::{ByteRecord, ByteRecordIter};
-use error::Error;
+use error::{Error, ErrorKind... | 7 | 176 | 85 |
b8175c44cbb6d815bfd310e35a1130f65581940d | Andrew Gallant | 2017-05-25T02:27:56 | csv/writer: optimize writing.
This commit optimizers the writer in the CSV crate. In particular, it adds
a fast pass that completely bypasses the CoreWriter from csv-core. It's
faster because the csv-core (necessarily) does a bunch of book-keeping to
maintain the state of the writer to allow for incremental writing.
... | diff --git a/benches/bench.rs b/benches/bench.rs
index 7e2c25f..637771b 100644
--- a/benches/bench.rs
+++ b/benches/bench.rs
@@ -11,7 +11,7 @@ use std::io;
use serde::de::DeserializeOwned;
use test::Bencher;
-use csv::{ByteRecord, Reader, ReaderBuilder, StringRecord};
+use csv::{ByteRecord, Reader, ReaderBuilder, S... | 2 | 219 | 14 |
f617f8ffa6c9b3344ef6b57c6a2f95653f8818d7 | Andrew Gallant | 2017-05-25T02:22:58 | csv-core/writer: export configuration settings.
This makes the CSV configuration available to consumers. | diff --git a/csv-core/src/writer.rs b/csv-core/src/writer.rs
index 362f14b..488a23b 100644
--- a/csv-core/src/writer.rs
+++ b/csv-core/src/writer.rs
@@ -432,6 +432,43 @@ impl Writer {
}
}
+ /// Return the delimiter used for this writer.
+ #[inline]
+ pub fn get_delimiter(&self) -> u8 {
+ ... | 1 | 37 | 0 |
6386542259e443666ef4c50129d866296e72bddf | Andrew Gallant | 2017-05-25T02:21:52 | csv-core/writer: optimizations
This optimizes the CSV core writer, and in particular, the routine that
determines whether some data needs to be quoted or not. We move from a
slow conditional check to a simple lookup table + loop unrolling. | diff --git a/csv-core/src/writer.rs b/csv-core/src/writer.rs
index 44ca3b7..362f14b 100644
--- a/csv-core/src/writer.rs
+++ b/csv-core/src/writer.rs
@@ -1,3 +1,4 @@
+use core::fmt;
use core::str;
use memchr::memchr;
@@ -8,7 +9,7 @@ use {QuoteStyle, Terminator};
///
/// This builder permits specifying the CSV deli... | 1 | 105 | 24 |
6641c4b5e5380534dd7724f3586d1fed09e0996e | Andrew Gallant | 2017-05-25T02:20:28 | csv-core/writer: export functions
This exports the `quote` and `is_non_numeric` functions. | diff --git a/csv-core/src/lib.rs b/csv-core/src/lib.rs
index e9028d4..2f46213 100644
--- a/csv-core/src/lib.rs
+++ b/csv-core/src/lib.rs
@@ -108,7 +108,7 @@ pub use reader::{
ReadFieldResult, ReadFieldNoCopyResult,
ReadRecordResult, ReadRecordNoCopyResult,
};
-pub use writer::{Writer, WriterBuilder, WriteRes... | 1 | 1 | 1 |
19cc86561f7c51622bd9bc3a1cda17a7052e3c54 | Andrew Gallant | 2017-05-24T22:19:21 | csv: re-define QuoteStyle and Terminator types.
Re-exporting the QuoteStyle and Terminator types through csv from csv-core
causes csv-core to be a public dependency of csv, which is bad juju.
Instead, redefine the types in csv. | diff --git a/csv-core/src/lib.rs b/csv-core/src/lib.rs
index f18904c..e9028d4 100644
--- a/csv-core/src/lib.rs
+++ b/csv-core/src/lib.rs
@@ -104,11 +104,89 @@ extern crate arrayvec;
extern crate memchr;
pub use reader::{
- Reader, ReaderBuilder, Terminator,
+ Reader, ReaderBuilder,
ReadFieldResult, ReadF... | 6 | 179 | 87 |
0143407c44b1caaead235585fa3a4cdac139685f | Adolfo Ochagavía | 2017-05-23T11:44:27 | Fix typo | diff --git a/src/tutorial.rs b/src/tutorial.rs
index dfe2690..7b5f219 100644
--- a/src/tutorial.rs
+++ b/src/tutorial.rs
@@ -478,7 +478,7 @@ StringRecord(["Oakman", "AL", "", "33.7133333", "-87.3886111"])
This example contains two new pieces of code:
1. Code for querying the positional arguments of your program. We... | 1 | 1 | 1 |
ec7c348bc53e68b3c26556f677697ec1e4d965bb | Andrew Gallant | 2017-05-23T02:00:00 | add rfc 4180 caveat to csv-core | diff --git a/csv-core/src/writer.rs b/csv-core/src/writer.rs
index 2808051..744aa98 100644
--- a/csv-core/src/writer.rs
+++ b/csv-core/src/writer.rs
@@ -68,10 +68,10 @@ impl WriterBuilder {
/// The record terminator to use when writing CSV.
///
- /// A record terminator can be any single byte. The defaul... | 1 | 8 | 3 |
5c21f12181ae300680675d15893f470d8439b036 | Andrew Gallant | 2017-05-23T01:28:08 | add badges | diff --git a/Cargo.toml b/Cargo.toml
index da6c17f..0ca59f4 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -11,6 +11,10 @@ keywords = ["csv", "comma", "parser", "delimited", "serde"]
license = "Unlicense/MIT"
categories = ["encoding", "parser-implementations"]
+[badges]
+travis-ci = { repository = "BurntSushi/rust-csv... | 3 | 12 | 0 |
609c640dcec72df7b7b27da3a5eb14c868e1a8b6 | Andrew Gallant | 2017-05-23T01:26:47 | add categories | diff --git a/Cargo.toml b/Cargo.toml
index 3d5551d..da6c17f 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -9,6 +9,7 @@ repository = "https://github.com/BurntSushi/rust-csv"
readme = "README.md"
keywords = ["csv", "comma", "parser", "delimited", "serde"]
license = "Unlicense/MIT"
+categories = ["encoding", "parser-impl... | 3 | 3 | 0 |
299658e232d46587f33b9d66fcebd92c19197cbd | Eric Findlay | 2017-03-27T01:12:41 | Corrected minor grammatical slip | diff --git a/src/lib.rs b/src/lib.rs
index a2ba908..371ee26 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -171,7 +171,7 @@
//! This behavior may be turned off by calling `flexible` with `true`.
//! * Empty lines (that do not include other whitespace) are ignored
//! by the parser.
-//! * This crates parses... | 1 | 1 | 1 |
cfc1ff2b4ab2abdb49dfa6b16e1f9ef1ca9aea37 | Nathan Rashleigh | 2017-03-21T05:54:30 | Update reader.rs
just a little typo,
love the project! | diff --git a/src/reader.rs b/src/reader.rs
index 98e9803..81cfae6 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -311,7 +311,7 @@ impl<R: io::Read> Reader<R> {
/// Returns a *copy* of the first record in the CSV data as strings.
///
/// This method may be called at any time and regardless of whether
-... | 1 | 2 | 2 |
b65cca3ccdca75425e36e8a6eb127152363d3bec | Florian Hartwig | 2016-10-13T17:30:53 | Use memchr to find quote characters | diff --git a/Cargo.toml b/Cargo.toml
index 16cdfee..88238f1 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -24,6 +24,7 @@ doc = false
[dependencies]
byteorder = "0.5"
rustc-serialize = "0.3"
+memchr = "0.1.11"
[dev-dependencies]
regex = "0.1"
diff --git a/src/lib.rs b/src/lib.rs
index 1d80a1f..a2ba908 100644
--- a/... | 3 | 4 | 1 |
b8a0baece4106b35ff917dd31e4a539c00201168 | Florian Hartwig | 2016-10-12T21:12:53 | Use `extend_from_slice` instead of iterator `extend` | diff --git a/src/writer.rs b/src/writer.rs
index fc75441..ef3813c 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -445,11 +445,11 @@ impl<W: io::Write> Writer<W> {
loop {
match s.iter().position(|&v| v == self.quote) {
None => {
- buf.extend(s.iter().map(|&x|x... | 1 | 2 | 2 |
77547b54aa97cd75e616ccdf482a5269f79d544c | Andrew Gallant | 2016-07-31T19:06:52 | Fix rdr.done() (again).
It is much more convenient for rdr.done() to return true if and only if
no more records will be emitted on subsequent calls to next_bytes/next_str. | diff --git a/src/reader.rs b/src/reader.rs
index cacf6a4..98e9803 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -626,8 +626,8 @@ impl<R: io::Read> Reader<R> {
return NextField::Error(Error::Io(err));
}
if self.buf.len() == 0 {
+ self.eof = true;
... | 2 | 18 | 6 |
cd4e6aa61147befdce9ab80072392d5b2be5db46 | Andrew Gallant | 2016-07-31T18:23:15 | Fix a bug where rdr.done() could return true prematurely.
It should only return true once the CSV reader has reached its final state. | diff --git a/src/reader.rs b/src/reader.rs
index 12eee17..cacf6a4 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -626,8 +626,8 @@ impl<R: io::Read> Reader<R> {
return NextField::Error(Error::Io(err));
}
if self.buf.len() == 0 {
- self.eof = true;
... | 2 | 22 | 1 |
928df2f962ff916236c8ebbdd3f89ec960bb5394 | Andrew Gallant | 2016-07-31T13:42:55 | bump to latest byteorder crate | diff --git a/Cargo.toml b/Cargo.toml
index c04703d..5fc4276 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -22,7 +22,7 @@ bench = false
doc = false
[dependencies]
-byteorder = "0.3"
+byteorder = "0.5"
rustc-serialize = "0.3"
[dev-dependencies]
diff --git a/src/lib.rs b/src/lib.rs
index 87f5a07..1d80a1f 100644
--- ... | 2 | 1 | 12 |
a3c28177518d608c35ba6c972ea2e90d9db1eead | Karol Kuczmarski | 2016-03-26T21:44:29 | Add Writer::into_string and Writer::into_bytes methods | diff --git a/src/writer.rs b/src/writer.rs
index e3e8e25..fc75441 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -117,7 +117,7 @@ impl<W: io::Write> Writer<W> {
impl Writer<Vec<u8>> {
/// Creates a new CSV writer that writes to an in memory buffer. At any
- /// time, `to_string` or `to_bytes` can be calle... | 1 | 20 | 2 |
11a59d6abe86d9c17ea183fa65674cbe94a4c551 | Andrew Gallant | 2015-04-04T03:18:05 | Fix clone. | diff --git a/src/reader.rs b/src/reader.rs
index 395e6e9..c9a2bae 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -23,7 +23,7 @@ use self::ParseState::{
///
/// Generally, you won't need to use this type because `CRLF` is the default,
/// which is by far the most widely used record terminator.
-#[derive(Copy)]
+#[... | 2 | 4 | 4 |
25d9af82de0c22bf1a0b5b787244ffe373323d78 | Andrew Gallant | 2015-03-26T20:48:59 | more rustup | diff --git a/src/lib.rs b/src/lib.rs
index a70be27..73b681b 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -179,7 +179,7 @@
#![deny(missing_docs)]
#![cfg_attr(test, feature(test))]
-#![feature(convert, core, io, into_cow, std_misc, unicode)]
+#![feature(convert, io, into_cow, std_misc, unicode)]
extern crate byteor... | 1 | 2 | 2 |
223f143ff3efc8dc89f3e1aa20cfb17e4b43525d | Edward Clarke | 2015-03-26T19:24:58 | rustup, fix writer.rs | diff --git a/src/writer.rs b/src/writer.rs
index 9d35078..6ae169d 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -66,7 +66,7 @@ pub enum QuoteStyle {
/// assert!(result.is_ok());
/// }
/// ```
-pub struct Writer<W> {
+pub struct Writer<W: Write> {
buf: io::BufWriter<W>,
delimiter: u8,
record_te... | 1 | 1 | 1 |
c3cc2731459f264629120e1896fb7c178f3113dd | Andrew Gallant | 2015-03-19T20:27:25 | rustup
Fixes #26. | diff --git a/src/decoder.rs b/src/decoder.rs
index 936e9a9..1dfaaca 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -110,7 +110,7 @@ impl serialize::Decoder for Decoded {
fn read_enum_variant<T, F>(&mut self, names: &[&str], mut f: F)
-> Result<T>
where F: FnMut(&mut... | 3 | 3 | 7 |
c22948c0e2926c0c9675b742953fcdf289773a01 | Andrew Gallant | 2015-03-03T02:10:10 | still on old_io unfortunately | diff --git a/Cargo.toml b/Cargo.toml
index c37d239..7dee39c 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -14,7 +14,7 @@ license = "Unlicense"
name = "csv"
[dependencies]
-rustc-serialize = "*"
+rustc-serialize = "0.2.0"
[dev-dependencies]
regex = "*" | 1 | 1 | 1 |
c415e7e98828a28cced0844567113dd14c285092 | Andrew Gallant | 2015-02-21T04:30:49 | rustup.
I had to remove a few trait impls on `ByteString`, so this might make it
a breaking change. I'm not sure how to fix it at the moment, other than
converting a `ByteString` into a `Vec<u8>` (doable without allocating)
and using that instead.
[breaking-change] | diff --git a/examples/nfl_plays.rs b/examples/nfl_plays.rs
index eb489e6..8288762 100644
--- a/examples/nfl_plays.rs
+++ b/examples/nfl_plays.rs
@@ -1,4 +1,4 @@
-#![feature(path)]
+#![feature(old_path)]
extern crate csv;
extern crate "rustc-serialize" as rustc_serialize;
diff --git a/examples/simple.rs b/examples/s... | 9 | 34 | 34 |
cf8ce7fe615e756399ab61db4cb4365d9f40b545 | Andrew Gallant | 2015-02-03T22:11:36 | Tweak 'FromStr' error type. | diff --git a/examples/rational_numbers.rs b/examples/rational_numbers.rs
index 0b214c7..4efaf59 100644
--- a/examples/rational_numbers.rs
+++ b/examples/rational_numbers.rs
@@ -31,19 +31,18 @@ impl Decodable for Rational {
}
impl str::FromStr for Rational {
- type Err = csv::Error;
+ type Err = String;
... | 1 | 8 | 9 |
96468d0a53dfa4a6de8c7932a8cad440f9b6066a | Tim Habermaas | 2015-02-03T22:02:38 | Fix rational_numbers example (from_str now returns Result, not Option).
Also: Remove warning about unnecessary `mut`. | diff --git a/examples/rational_numbers.rs b/examples/rational_numbers.rs
index bc0e7e6..0b214c7 100644
--- a/examples/rational_numbers.rs
+++ b/examples/rational_numbers.rs
@@ -1,7 +1,7 @@
//! This example shows how to write your own custom implementation of
//! `Decodable` to parse rational numbers.
-#![feature(co... | 2 | 12 | 7 |
6d5d16571c73255d6fe1a8598bf9fa8277897640 | Tim Habermaas | 2015-02-03T21:33:28 | Make decoder work with newest nightly build.
`FromStr::from_str` now returns `Result` not `Option`. | diff --git a/src/decoder.rs b/src/decoder.rs
index 0db0a80..1f0e538 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -53,8 +53,8 @@ impl Decoded {
let s = try!(self.pop_string());
let s = s.trim();
match FromStr::from_str(s) {
- Some(t) => Ok(t),
- None => self.err(fo... | 1 | 2 | 2 |
c3c8537bf81f66d8b0cb935e281feff231eeee2e | Andrew Gallant | 2015-02-02T17:55:14 | more rustup | diff --git a/src/test.rs b/src/test.rs
index 5c99e33..fc0a450 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -236,7 +236,7 @@ parses_to!(flexible_rows2, "a,b\nx", vec![vec!["a", "b"], vec!["x"]],
fail_parses_to!(nonflexible, "a\nx,y", vec![]);
fail_parses_to!(nonflexible2, "a,b\nx", vec![]);
-#[derive(RustcDecodable... | 1 | 1 | 1 |
ff28a58f4cdfdc6b4aa9405b5a2f617daa811d55 | Ewan Higgs | 2015-02-02T13:31:45 | Show was renamed to Debug
https://github.com/rust-lang/rust/pull/21457/commits | diff --git a/src/lib.rs b/src/lib.rs
index 592142c..58f7813 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -219,7 +219,7 @@ mod test;
pub type CsvResult<T> = Result<T, Error>;
/// An error produced by an operation on CSV data.
-#[derive(Clone, Show)]
+#[derive(Clone, Debug)]
pub enum Error {
/// An error reporte... | 2 | 6 | 6 |
57ae326da27f6e7ca2281c7c9a46733237268688 | Ewan Higgs | 2015-02-02T13:30:34 | RullRange was renamed to RangeFull
https://github.com/rust-lang/rust/pull/21717 | diff --git a/src/bytestr.rs b/src/bytestr.rs
index ca7d9f0..78af92f 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -179,10 +179,10 @@ impl ops::Deref for ByteString {
}
}
-impl ops::Index<ops::FullRange> for ByteString {
+impl ops::Index<ops::RangeFull> for ByteString {
type Output = [u8];
- fn i... | 1 | 2 | 2 |
093450dd63b51894a11f80ca8356f5aea3be4aac | Zbigniew Siciarz | 2015-01-31T16:17:58 | rustup - FullRange -> RangeFull | diff --git a/src/bytestr.rs b/src/bytestr.rs
index ca7d9f0..78af92f 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -179,10 +179,10 @@ impl ops::Deref for ByteString {
}
}
-impl ops::Index<ops::FullRange> for ByteString {
+impl ops::Index<ops::RangeFull> for ByteString {
type Output = [u8];
- fn i... | 1 | 2 | 2 |
9fbf2061a73c2f667111b23024a228aa97409d7a | Alex Chandel | 2015-01-23T16:47:00 | Fix build for Show/String->Debug/Display. | 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: &... | 5 | 11 | 11 |
fb25612b2057901a44093bd07f8ddf3cb117573e | Andrew Gallant | 2015-01-10T04:58:01 | It seems auto-deref'ing still has problems with hashing.
Maybe I'm doing something wrong? Not sure. But `self.hash(hasher)`
is significantly slower in some of my `xsv` benchmarks. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 6ed655e..470a9c0 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -211,7 +211,7 @@ impl ops::Index<ops::Range<usize>> for ByteString {
}
}
-impl<H: hash::Hasher> hash::Hash<H> for ByteString {
+impl<H: hash::Hasher + hash::Writer> hash::Hash<H> for ByteStrin... | 1 | 2 | 2 |
5505f1287c079a9fc9de1f496398da5d9617df38 | Andrew Gallant | 2015-01-07T22:53:50 | old_orphan_check isn't needed I guess | diff --git a/src/lib.rs b/src/lib.rs
index 52db902..c9e09b6 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -5,7 +5,6 @@
#![deny(missing_docs)]
#![feature(slicing_syntax)]
-#![feature(old_orphan_check)] // see rustc commit c61a00
//! This crate provides a streaming CSV (comma separated values) writer and
//! reader... | 1 | 0 | 1 |
a72de47e9b87cab2c954e7f0e66f5e13525816b1 | Andrew Gallant | 2015-01-04T18:27:38 | Better use of associated types. | diff --git a/src/writer.rs b/src/writer.rs
index b7f964b..66ddca9 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -233,8 +233,8 @@ impl<W: io::Writer> Writer<W> {
///
/// assert_eq!(wtr.as_bytes(), b"\xff,\x00\n");
/// ```
- pub fn write<'a, I, F>(&mut self, r: I) -> CsvResult<()>
- where... | 1 | 2 | 2 |
c46fd01e70d08fe19ef965ba3f98242502838937 | JP-Ellis | 2015-01-04T01:47:15 | Update to latest Rust.
Fixes `deriving` being renamed to `derive`, and partial fix for
associated types (still need to wait for certain traits to implement
associated types).
Signed-off-by: JP-Ellis <coujellis@gmail.com> | diff --git a/src/bench.rs b/src/bench.rs
index 93edfa7..320440b 100644
--- a/src/bench.rs
+++ b/src/bench.rs
@@ -1,5 +1,5 @@
use std::fmt::Show;
-use std::io::{mod, ByRefReader};
+use std::io::{self, ByRefReader};
use std::io::Reader as IoReader;
use stdtest::Bencher;
diff --git a/src/bytestr.rs b/src/bytestr.rs
i... | 6 | 19 | 14 |
9d6da9a613cd3be060996080807874ffc033c806 | Andrew Gallant | 2014-12-30T15:14:58 | Add version tag | diff --git a/Cargo.toml b/Cargo.toml
index 0971ff4..ec7d856 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,6 +1,6 @@
[package]
name = "csv"
-version = "0.12.0"
+version = "0.12.0" #:version
authors = ["Andrew Gallant <jamslam@gmail.com>"]
description = "CSV parsing with automatic type based decoding and encoding."... | 1 | 1 | 1 |
0c9b985f61bb3929ab32817f6b9e7ad35353ba43 | Zbigniew Siciarz | 2014-12-30T14:48:57 | rustup - fix mutable slice syntax. | diff --git a/src/buffered.rs b/src/buffered.rs
index a39057f..1bdc3c4 100644
--- a/src/buffered.rs
+++ b/src/buffered.rs
@@ -50,7 +50,7 @@ impl<R: Reader> BufferedReader<R> {
impl<R: Reader> Buffer for BufferedReader<R> {
fn fill_buf<'a>(&'a mut self) -> IoResult<&'a [u8]> {
if self.pos == self.cap {
- ... | 1 | 1 | 1 |
ce6d080bba97a399d00f5aa815fb1bfc4e68fe05 | Andrew Gallant | 2014-12-26T14:41:35 | Add an example derived from #15. | diff --git a/examples/rational_numbers.rs b/examples/rational_numbers.rs
new file mode 100644
index 0000000..6afbcfa
--- /dev/null
+++ b/examples/rational_numbers.rs
@@ -0,0 +1,55 @@
+//! This example shows how to write your own custom implementation of
+//! `Decodable` to parse rational numbers.
+
+extern crate csv;
+... | 1 | 55 | 0 |
3984159ad5463bfbb3b8c30d7b4005d1ae59adb7 | Andrew Gallant | 2014-12-24T02:07:41 | Move back to StrAllocating.
This defines a `StrAllocating` trait and switches back to taking strings
by value in several public functions.
This is hopefully a temporary measure until the standard library
provides more impls for a trait like `IntoString`.
I switched back because the `ToOwned` trait is *not* a suitabl... | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 25af220..3345e52 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -72,6 +72,23 @@ impl<'a, Sized? T: BorrowBytes> BorrowBytes for &'a T {
fn borrow_bytes(&self) -> &[u8] { (*self).borrow_bytes() }
}
+/// Encapsulate allocating of strings.
+///
+/// This is a... | 6 | 45 | 31 |
ea505ae6a7b8f63d4b3f7050b264636d57fe247c | Andrew Gallant | 2014-12-24T00:43:58 | Rustup.
This required a couple breaking changes.
Firstly, we've moved to using `rustc_serialize` instead of `serialize`,
since the latter has been deprecated. This requires you to change:
extern crate serialize;
to
extern crate "rustc-serialize" as rustc_serialize;
And all instances of `deriving(Decodable... | diff --git a/Cargo.toml b/Cargo.toml
index e017b4b..fe35ff9 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,6 +13,9 @@ license = "Unlicense"
[lib]
name = "csv"
+[dependencies]
+rustc-serialize = "*"
+
[profile.bench]
opt-level = 3
lto = true # this doesn't seem to work... why?
diff --git a/examples/nfl_plays.rs... | 12 | 66 | 51 |
87a983f3f5c9b5eefdf1575f3cce7973bf126bf4 | Andrew Gallant | 2014-12-22T23:33:01 | Fix the stream example. | diff --git a/examples/stream.rs b/examples/stream.rs
index 4bddef4..d75d1b1 100644
--- a/examples/stream.rs
+++ b/examples/stream.rs
@@ -2,28 +2,24 @@ extern crate csv;
use std::comm::channel;
use std::io;
-use std::task::spawn;
+use std::thread::Thread;
use std::time::Duration;
fn main() {
let (send, recv... | 1 | 7 | 11 |
943d0ad2757252cdb820420c8d5bcef00bd13ed4 | Andrew Gallant | 2014-12-22T23:32:50 | Add a comment about why from_buffer is private. | diff --git a/src/reader.rs b/src/reader.rs
index f7eee3c..270034c 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -129,6 +129,9 @@ impl<R: io::Reader> Reader<R> {
/// This allows you to create your own buffer with a capacity of your
/// choosing. In all other constructors, a buffer with default capacity
... | 1 | 3 | 0 |
b34ed741155672c21e8c36604b300b3d75e2e026 | Andrew Gallant | 2014-12-22T01:11:34 | Abstract over strings and raw bytes in csv::Writer.
This is done by defining a trait, `BorrowBytes`, that knows
how to extract raw bytes from various types (like Strings and
Vec<u8>). This also supports copy-on-writer pointers (`Cow`s).
This gets rid of the need for both a `write` and `write_bytes`
method. They have ... | diff --git a/src/bytestr.rs b/src/bytestr.rs
index b97fd1c..3cd5d8a 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -1,3 +1,4 @@
+use std::borrow::{BorrowFrom, Cow, ToOwned};
use std::fmt;
use std::hash;
use std::ops;
@@ -16,6 +17,10 @@ impl<'a, T: Clone> IntoVector<T> for &'a [T] {
fn into_vec(self) -> Vec... | 3 | 78 | 39 |
718a8bf64d9924a9873f3aeaed6a9417a7856d6c | JP-Ellis | 2014-12-20T09:35:28 | Two fixes for changes in rust and in serialize crate.
Have a fix for breaking change introduce in rust commit ddb2466 which
now parses `macro!()` and `macro![]` as expressions if not followed by a
semi-colon.
Also fixed a change in the Serialize crate resulting in FnMut being used
instead of FnOnce.
Signed-off-by: J... | diff --git a/src/decoder.rs b/src/decoder.rs
index 132b15f..46e4d51 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -104,9 +104,9 @@ impl serialize::Decoder<Error> for Decoded {
where F: FnOnce(&mut Decoded) -> CsvResult<T> {
f(self)
}
- fn read_enum_variant<T, F>(&mut self, names: &[&... | 2 | 117 | 117 |
f826366ce98c88d8ff389b3e030e4fd8f71a4b23 | Andrew Gallant | 2014-12-19T00:54:40 | Tweak quotes so that it's possible to specify that quotes should
never be used.
This is more useful in the encoder, where encoding a field that requires
quotes will report an error (only when `QuoteStyle::Never` is used).
On the parsing side, this could possibly lead to more efficient parsers.
(But I'm skeptical of a... | diff --git a/src/reader.rs b/src/reader.rs
index 68a29e2..481d1f1 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -134,7 +134,7 @@ impl<R: io::Reader> Reader<R> {
pmachine: ParseMachine {
delimiter: b',',
record_terminator: RecordTerminator::CRLF,
- quote:... | 3 | 57 | 19 |
01b1aab66674f7b78d67eabb2e67caa0783199c9 | Andrew Gallant | 2014-12-19T00:51:26 | Use `while let`. | diff --git a/src/lib.rs b/src/lib.rs
index 284758f..00359f5 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -132,12 +132,8 @@
//!
//! let mut rdr = csv::Reader::from_string(data);
//! while !rdr.done() {
-//! loop {
-//! let field = match rdr.next_field().into_iter_result() {
-//! None => break,
... | 3 | 6 | 20 |
cfd2f07ef0516bce448bf5dc5f5d4b2795048bf7 | Andrew Gallant | 2014-12-19T00:50:30 | Fix up benchmark.
Option can no longer handle bad decodes (it can only handle
empty fields).
Use `while let`. | diff --git a/src/bench.rs b/src/bench.rs
index 73960d4..9426a73 100644
--- a/src/bench.rs
+++ b/src/bench.rs
@@ -32,11 +32,8 @@ fn raw_records(b: &mut Bencher) {
b.iter(|| {
let mut dec = reader(&mut data);
while !dec.done() {
- loop {
- match dec.next_field().into_iter_... | 1 | 11 | 14 |
b7cb50d4b088aba4e1bbc2f23c663314735bd8be | Andrew Gallant | 2014-12-17T16:17:19 | Cripple the decoder to work with FnOnce. | diff --git a/examples/stream.rs b/examples/stream.rs
index 02a9fe3..4bddef4 100644
--- a/examples/stream.rs
+++ b/examples/stream.rs
@@ -7,7 +7,7 @@ use std::time::Duration;
fn main() {
let (send, recv) = channel();
- spawn(proc() {
+ spawn(move || {
let w = io::ChanWriter::new(send);
le... | 4 | 25 | 58 |
841fb82b468b97916db80f5de7c5549f8e9d695a | Andrew Gallant | 2014-12-16T12:26:38 | Nearly complete update to latest Rust.
The last remaining issue is enum decoding. My (very hacky) approach
requires at least a FnMut, but the `Decoder` trait requires a FnOnce. | diff --git a/src/decoder.rs b/src/decoder.rs
index a622421..d38f8e9 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -100,14 +100,13 @@ impl serialize::Decoder<Error> for Decoded {
fn read_str(&mut self) -> CsvResult<String> {
self.pop_string()
}
- fn read_enum<T>(&mut self, _: &str,
- ... | 2 | 83 | 95 |
0e4827101850e854259b67a6f32dc939e544f2b1 | Andrew Gallant | 2014-12-15T01:11:20 | A bit of internal refactoring.
This also seems to have made the parser slightly faster,
but I only have vague guesses as to why. | diff --git a/src/reader.rs b/src/reader.rs
index 4bb6c4a..a4cd284 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -83,11 +83,7 @@ impl PartialEq<u8> for RecordTerminator {
/// }
/// ```
pub struct Reader<R> {
- delimiter: u8,
- record_terminator: RecordTerminator,
- quote: u8,
- escape: u8,
- double... | 1 | 77 | 84 |
dc1104bb6fcd4056b9ab52d724696c73552278ba | Andrew Gallant | 2014-12-13T19:31:44 | Add `unsafe` for transmuting.
The world is right again. | diff --git a/src/reader.rs b/src/reader.rs
index 62456a3..f2508fe 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -966,7 +966,9 @@ impl<'a, R: io::Reader> Iterator<CsvResult<&'a [u8]>>
fn next(&mut self) -> Option<CsvResult<&'a [u8]>> {
// whoa... why is this allowed!?
// TODO: Construct a mini... | 1 | 3 | 1 |
7e95f1f7aeede11c47436a8ecd2c8f889c86dee5 | JP-Ellis | 2014-12-10T13:31:53 | Implemented Copy.
Implemented Copy for ParseError, ParseErrorKind, RecordTerminator and
QuoteStyle.
Signed-off-by: JP-Ellis <coujellis@gmail.com> | diff --git a/src/lib.rs b/src/lib.rs
index c140448..284758f 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -248,7 +248,7 @@ impl Error {
}
/// A description of a CSV parse error.
-#[deriving(Clone)]
+#[deriving(Clone, Copy)]
pub struct ParseError {
/// The line number of the parse error.
pub line: u64,
@@ -... | 3 | 4 | 2 |
47e12fa878c152528a0f944d7c69a9946b60a0a0 | Andrew Gallant | 2014-12-07T20:48:25 | Small tweak. | diff --git a/src/reader.rs b/src/reader.rs
index 4a9fcbc..62456a3 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -1,5 +1,4 @@
use std::io::{mod, MemReader};
-use std::mem::transmute;
use serialize::Decodable;
@@ -1086,5 +1085,5 @@ fn byte_record_to_utf8(record: Vec<ByteString>) -> CsvResult<Vec<String>> {
... | 1 | 1 | 2 |
f84bb931d70f70eb0cd752b6133431ab81bc3007 | Andrew Gallant | 2014-12-07T20:13:08 | Try to use lto for benchmarks?
(Doesn't seem to actually work.) | diff --git a/Cargo.toml b/Cargo.toml
index 78693d1..4dff5fc 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -12,3 +12,7 @@ license = "Unlicense"
[lib]
name = "csv"
+
+[profile.bench]
+opt-level = 3
+lto = true # this doesn't seem to work... why? | 1 | 4 | 0 |
4e6e54350f1bb52a1ad960fb6c1b570cc61f9f0d | Andrew Gallant | 2014-12-07T20:12:54 | Document write_results, even though it is undocumented. | diff --git a/src/writer.rs b/src/writer.rs
index 0511926..176d68b 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -246,6 +246,8 @@ impl<W: io::Writer> Writer<W> {
self.write_iter(r, |f| Ok(f))
}
+ /// Writes a record of results. If any of the results resolve to an error,
+ /// then writing stops... | 1 | 2 | 0 |
f6130c560e14eb6a5b8589b10f06026037ca5f18 | Andrew Gallant | 2014-12-07T19:36:47 | Remove temporary trait hack for Sized? `Str` impls. | diff --git a/src/writer.rs b/src/writer.rs
index 036cbbb..0511926 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -68,21 +68,6 @@ pub struct Writer<W> {
first_len: uint,
}
-/// This is a (hopefully) temporary trait until the standard library gets
-/// its act together.
-pub trait SizedStr for Sized? {
- //... | 1 | 2 | 17 |
baa849979e2b6b0953f35b6199e5de1ab8915e2d | Andrew Gallant | 2014-12-07T19:33:00 | Drop MemWriter in favor of Vec<u8>. | diff --git a/src/writer.rs b/src/writer.rs
index 34d7fe3..036cbbb 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -122,32 +122,32 @@ impl<W: io::Writer> Writer<W> {
}
}
-impl Writer<io::MemWriter> {
+impl Writer<Vec<u8>> {
/// Creates a new CSV writer that writes to an in memory buffer. At any
/// t... | 1 | 9 | 9 |
7a76119367a88d37f962ab52801c889dc0cdf9a5 | Andrew Gallant | 2014-12-07T19:32:48 | Explain the purpose of src/buffered.rs. | diff --git a/src/buffered.rs b/src/buffered.rs
index 3a028a9..a39057f 100644
--- a/src/buffered.rs
+++ b/src/buffered.rs
@@ -1,3 +1,6 @@
+// This is a copy of the `std::io::BufferedReader` with one additional
+// method: `clear`. It resets the buffer to be empty (thereby losing any
+// unread data).
use std::cmp;
use... | 1 | 9 | 3 |
4e937db06a380320c8b3f301fd41a77a710ee27f | Andrew Gallant | 2014-12-07T19:32:34 | Use `get_mut` instead of `get_mut_ref` (naming convention). | diff --git a/src/buffered.rs b/src/buffered.rs
index 46887ea..3a028a9 100644
--- a/src/buffered.rs
+++ b/src/buffered.rs
@@ -34,7 +34,8 @@ impl<R: Reader> BufferedReader<R> {
BufferedReader::with_capacity(DEFAULT_BUF_SIZE, inner)
}
- pub fn get_mut_ref<'a>(&'a mut self) -> &'a mut R { &mut self.inner... | 2 | 3 | 2 |
1cc8349b8cce0aa6684db3acd0faf058e9643656 | Andrew Gallant | 2014-12-07T18:56:12 | \o/ if_let and tuple_indexing are unfeature gated. | diff --git a/src/lib.rs b/src/lib.rs
index 0ffb563..c140448 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -4,8 +4,7 @@
#![experimental]
#![deny(missing_docs)]
-#![feature(default_type_params, if_let, macro_rules,
- slicing_syntax, tuple_indexing)]
+#![feature(default_type_params, macro_rules, slicing_syntax... | 1 | 1 | 2 |
371ac8a0495757b9d0fcf02d53f6feeb1ce18558 | Andrew Gallant | 2014-12-05T23:14:57 | Expunge uses of Equiv (which is now deprecated). | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 15bd4dc..b97fd1c 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -146,8 +146,8 @@ impl<H: hash::Writer> hash::Hash<H> for ByteString {
}
}
-impl<S: Str> Equiv<S> for ByteString {
- fn equiv(&self, other: &S) -> bool {
+impl<S: Str> PartialEq<S> for ByteS... | 3 | 6 | 6 |
4b8525835c03aef521edeec47f5f89d4ef355a20 | Andrew Gallant | 2014-12-02T16:35:43 | Remove unused/unnecessary attributes. | diff --git a/src/lib.rs b/src/lib.rs
index 56048e4..0ffb563 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -1,7 +1,4 @@
#![crate_name = "csv"]
-#![crate_type = "rlib"]
-#![crate_type = "dylib"]
-#![license = "UNLICENSE"]
#![doc(html_root_url = "http://burntsushi.net/rustdoc/csv")]
#![experimental] | 1 | 0 | 3 |
a73be5c42fbf7b6b9a2db498d13377cf98fbae9e | Andrew Gallant | 2014-12-02T01:10:06 | Unnecessary mutability. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 164cb01..15bd4dc 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -153,7 +153,7 @@ impl<S: Str> Equiv<S> for ByteString {
}
impl FromIterator<u8> for ByteString {
- fn from_iter<I: Iterator<u8>>(mut it: I) -> ByteString {
+ fn from_iter<I: Iterator<u8>>(it... | 1 | 1 | 1 |
8c9c3d3a254a4e408f49baf8be7eda487062c0f3 | Andrew Gallant | 2014-11-28T02:01:37 | Fix a doctest and explain a particular weird quoting rule. | diff --git a/src/writer.rs b/src/writer.rs
index 855b10f..124cdca 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -32,6 +32,11 @@ pub enum QuoteStyle {
/// flexible record lengths are enabled, then compliance with RFC 4180 cannot
/// be guaranteed.)
///
+/// One slight deviation is that records with a single empty... | 1 | 6 | 1 |
4d1551783637b02d3525c00e45ffcccda5cd0f50 | Andrew Gallant | 2014-11-28T01:55:28 | Make the reader/writer more configurable.
This adds support for changing quote characters, escaping styles,
quote styles and record terminators.
There should be only one breaking change: the `crlf` method has been
removed from `csv::Writer` and replaced with a more general
`record_terminator` method. Code that used `... | diff --git a/src/lib.rs b/src/lib.rs
index 541e821..56048e4 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -203,8 +203,9 @@ pub use encoder::Encoded;
pub use decoder::Decoded;
pub use reader::{
Reader, DecodedRecords, StringRecords, ByteRecords, NextField,
+ RecordTerminator,
};
-pub use writer::Writer;
+pub us... | 4 | 476 | 219 |
bfedc8a8034861cdd9fe4b393b863344ac6a377e | Andrew Gallant | 2014-11-28T01:52:34 | Better use of FromError. | diff --git a/src/index/mod.rs b/src/index/mod.rs
index 0b2fc25..69c46eb 100644
--- a/src/index/mod.rs
+++ b/src/index/mod.rs
@@ -1,5 +1,6 @@
#![allow(missing_docs)]
+use std::error::FromError;
use std::io;
use {CsvResult, Error, Reader, NextField};
@@ -12,8 +13,8 @@ pub struct Indexed<R, I> {
impl<R: io::Read... | 1 | 12 | 10 |
db5ad7b14dc99d4306389f2967f013712905f429 | Andrew Gallant | 2014-11-27T05:38:43 | Massive reform of tests.
This also adds a lot more tests. Interestingly, I only uncovered
one bug. Namely, decoding into enum variants does not work like it
says on the tin. I claimed that enum variants with and without an
argument were supported, but I don't think this is actually possible.
Therefore, support for de... | diff --git a/src/decoder.rs b/src/decoder.rs
index c55ca07..a622421 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -109,10 +109,15 @@ impl serialize::Decoder<Error> for Decoded {
f: |&mut Decoded, uint| -> CsvResult<T>)
-> CsvResult<T> {
let variant... | 4 | 426 | 458 |
4ab82650073fa7f81a170cc4ad7f414ede5c900f | Andrew Gallant | 2014-11-24T00:06:47 | Add `&str` and `String` impls to the `IntoVector` trait. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 6148352..164cb01 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -16,6 +16,14 @@ impl<'a, T: Clone> IntoVector<T> for &'a [T] {
fn into_vec(self) -> Vec<T> { self.to_vec() }
}
+impl<'a> IntoVector<u8> for &'a str {
+ fn into_vec(self) -> Vec<u8> { self.i... | 1 | 8 | 0 |
0b40a62f916c34121541b2df09d42dbb40c835f3 | Andrew Gallant | 2014-11-23T23:44:21 | Don't rely on Deref inside `hash`.
Apprently it introduces a major performance regression, probably
due to a spurious copy. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index df381fd..6148352 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -125,7 +125,16 @@ impl ops::Slice<uint, [u8]> for ByteString {
impl<H: hash::Writer> hash::Hash<H> for ByteString {
fn hash(&self, hasher: &mut H) {
- (&*self).hash(hasher);
+ //... | 1 | 10 | 1 |
c99397a61e6523e4d0acb728ccbdfa4ce7dabad4 | Andrew Gallant | 2014-11-23T03:22:32 | Renamed `as_utf8_string` to `into_utf8_string` because it takes
`self` by value.
[breaking-change] | diff --git a/src/bytestr.rs b/src/bytestr.rs
index dbc60bd..df381fd 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -57,7 +57,7 @@ impl ByteString {
/// Consumes the byte string and decodes it into a Unicode string. If the
/// decoding fails, then the original ByteString is returned.
- pub fn as_utf8... | 2 | 2 | 2 |
18524a4f03536f3e206c2ed9f0579f16bd453f92 | Andrew Gallant | 2014-11-23T03:22:04 | Impl Deref for ByteString.
This lets you do `&*some_byte_string` to get a slice of it.
You can also do `some_byte_string[]` to get a slice, but it seems
that the future of `[]` is murky. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index a41abbe..dbc60bd 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -47,14 +47,12 @@ impl ByteString {
/// Consumes this byte string into a vector of bytes.
pub fn into_bytes(self) -> Vec<u8> {
- let ByteString(chars) = self;
- chars
+ ... | 2 | 11 | 8 |
20f7727551f5f3143dec74445029ef2d294d2f66 | Andrew Gallant | 2014-11-22T04:05:03 | Embrace the lack of streaming iterators.
I don't see any relief for streaming iterators on the horizon. It seems
we are doomed until we get higher-kinded polymorphism.
In that case, we might as well make `next_field` a little more ergonomic.
Moreover, an extremely unsafe `byte_fields` iterator is provided. You
shoul... | diff --git a/src/bench.rs b/src/bench.rs
index 06cf206..73960d4 100644
--- a/src/bench.rs
+++ b/src/bench.rs
@@ -33,7 +33,7 @@ fn raw_records(b: &mut Bencher) {
let mut dec = reader(&mut data);
while !dec.done() {
loop {
- match dec.next_field() {
+ match dec... | 5 | 82 | 49 |
3011952f93be35c6fba420bfa581484a4d6e3be4 | Andrew Gallant | 2014-11-21T00:11:32 | Update to latest Rust.
This required some very weird changes in how record iterators are
accepted in the encoder. If you were using `write` to write a record
of `String`, you now need to provide an iterator of references rather
than an iterator of values. (i.e., Use `iter` instead of `into_iter`.)
Based on my reading... | diff --git a/Cargo.toml b/Cargo.toml
index a041c83..0d11b72 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -1,7 +1,14 @@
[package]
-name = "rust-csv"
+name = "csv"
version = "0.5.1"
authors = ["Andrew Gallant <jamslam@gmail.com>"]
+description = "CSV parsing with automatic type based decoding and encoding."
+documentat... | 4 | 30 | 8 |
20b63b360719d6a5ff55f31ed8b45e7cee1527ea | Andrii Dmytrenko | 2014-11-20T09:56:24 | Update to latest Rust. | diff --git a/src/encoder.rs b/src/encoder.rs
index 2af7c06..4711d59 100644
--- a/src/encoder.rs
+++ b/src/encoder.rs
@@ -133,7 +133,7 @@ impl serialize::Encoder<Error> for Encoded {
f(self)
}
fn emit_option_none(&mut self) -> CsvResult<()> {
- self.push_bytes::<&[u8]>([])
+ self.push_by... | 2 | 2 | 2 |
34be7bd832fb31679e43adf1f7bc344687c38a72 | Andrew Gallant | 2014-11-19T01:19:24 | 80 cols, please. | diff --git a/src/buffered.rs b/src/buffered.rs
index a69ce55..46887ea 100644
--- a/src/buffered.rs
+++ b/src/buffered.rs
@@ -17,9 +17,9 @@ impl<R: Reader> BufferedReader<R> {
// It's *much* faster to create an uninitialized buffer than it is to
// fill everything in with 0. This buffer is entirely an ... | 4 | 32 | 16 |
a9a51b6af36563ef3ae064346a58e0f8629cce88 | Andrew Gallant | 2014-11-19T01:15:19 | Fixes from enum namespace changes. | diff --git a/src/decoder.rs b/src/decoder.rs
index 0ca8358..fac6e84 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -3,7 +3,7 @@ use std::str::FromStr;
use serialize;
-use {ByteString, CsvResult, Error, ErrDecode};
+use {ByteString, CsvResult, Error};
/// A record to be decoded.
///
@@ -43,7 +43,8 @@ impl ... | 7 | 63 | 58 |
af7d2e2f6d3eb5f693e84c8e5fe0feb8ca78b403 | Andrew Gallant | 2014-11-17T13:07:50 | Update to latest Rust. | diff --git a/src/decoder.rs b/src/decoder.rs
index 3fc177d..0ca8358 100644
--- a/src/decoder.rs
+++ b/src/decoder.rs
@@ -1,5 +1,5 @@
use std::default::Default;
-use std::from_str::FromStr;
+use std::str::FromStr;
use serialize; | 1 | 1 | 1 |
d37229b25055ab1db9422cb111403737b9a94b3d | Alexander Malkov | 2014-11-17T12:45:59 | Fix the case when CSV file has \r only line endings.
Excel creates those when you export CSV.
The problem was that the line_current didn't increment (because it never met \n),
so it was copying everything into first_record. | diff --git a/src/reader.rs b/src/reader.rs
index 9c37111..9c2f5a7 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -489,6 +489,11 @@ impl<R: io::Reader> Reader<R> {
// After processing an EndRecord (and determined there are no
// errors), we should always start parsing the next record.
... | 2 | 13 | 0 |
8ed93326bda356d9e0a8ab9f2d281b2bf6ffab86 | Andrew Gallant | 2014-11-16T05:03:49 | Fix weird interaction with indexing.
Basically, if we've seeked, then we don't want to try and specially
handle headers in the record iterators. | diff --git a/src/reader.rs b/src/reader.rs
index 4e10933..9c37111 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -70,6 +70,12 @@ pub struct Reader<R> {
// Keep a copy of the first record parsed.
first_record: Vec<ByteString>,
+ // Is set if `seek` is ever called.
+ // This subtlely modifies the beh... | 1 | 10 | 1 |
4879230109dbee1bba3235949bf31beed775bd98 | Andrew Gallant | 2014-11-15T16:53:40 | Update to latest Rust. | diff --git a/src/bench.rs b/src/bench.rs
index aca61ae..06cf206 100644
--- a/src/bench.rs
+++ b/src/bench.rs
@@ -1,5 +1,5 @@
use std::fmt::Show;
-use std::io::{mod, AsRefReader};
+use std::io::{mod, ByRefReader};
use std::io::Reader as IoReader;
use stdtest::Bencher;
diff --git a/src/test.rs b/src/test.rs
index 24... | 2 | 2 | 2 |
7a216b4cf5616d34ed0f8896624740fb9b66241d | Andrew Gallant | 2014-11-10T02:53:59 | Read the headers at index creation.
Indexing is tricky because part of it fights against the internal
state of the CSV parser/iterators. One of the complexities of the
reader is the handling of headers, which is probably too clever for
its own good. To avoid running into weird errors, we force the
internal state to ha... | diff --git a/src/index/mod.rs b/src/index/mod.rs
index a0768ef..22dae8f 100644
--- a/src/index/mod.rs
+++ b/src/index/mod.rs
@@ -11,11 +11,12 @@ pub struct Indexed<R, I> {
}
impl<R: io::Reader + io::Seek, I: io::Reader + io::Seek> Indexed<R, I> {
- pub fn new(rdr: Reader<R>, mut idx: I) -> CsvResult<Indexed<R, I... | 1 | 2 | 1 |
1bacb0a78e2e9c8168c0ffffaa17bb5891e97fbd | Andrew Gallant | 2014-11-09T20:01:46 | Fix bug when counting CSV records for indexing. | diff --git a/src/index/mod.rs b/src/index/mod.rs
index 0fff21c..a0768ef 100644
--- a/src/index/mod.rs
+++ b/src/index/mod.rs
@@ -14,7 +14,7 @@ impl<R: io::Reader + io::Seek, I: io::Reader + io::Seek> Indexed<R, I> {
pub fn new(rdr: Reader<R>, mut idx: I) -> CsvResult<Indexed<R, I>> {
try!(idx.seek(-8, io:... | 1 | 4 | 3 |
920684f32dd4e8a3fd80ed62c096b07330131100 | Andrew Gallant | 2014-11-09T05:47:28 | Make records with a single empty string expressible.
Previously, encoding a record with a single empty string resulted
in an inconsistency between the reader and the writer. The writer
would encode it as a single new line character while the reader
only treats a new line character as a record separate if there is
non-... | diff --git a/src/test.rs b/src/test.rs
index b9909fc..24821ea 100644
--- a/src/test.rs
+++ b/src/test.rs
@@ -72,6 +72,13 @@ fn encoder_quoted_newlines() {
assert_eq!("\"spring\nsteen\"\n", senc.as_string());
}
+#[test]
+fn encoder_empty() {
+ let mut senc = Writer::from_memory();
+ ordie(senc.encode(vec!(... | 2 | 32 | 3 |
fe382eeb78e7542effe6daf5576b1aeb6fd9dde6 | Andrew Gallant | 2014-11-06T23:21:37 | Removes the convenience `collect` function.
I wrote this function back before I realized that `Result` implements
`FromIterator` for `Iterator<Result<T, E>>` where `T: FromIterator`.
So code that looks like:
let rows = csv::collect(rdr.records()).unwrap();
Should be replaced with:
let rows = rdr.records().... | diff --git a/examples/nfl_plays.rs b/examples/nfl_plays.rs
index a5bbfa4..c794c2a 100644
--- a/examples/nfl_plays.rs
+++ b/examples/nfl_plays.rs
@@ -25,7 +25,7 @@ fn main() {
let fp = &Path::new("./data/2012_nfl_pbp_data.csv");
let mut dec = csv::Reader::from_file(fp);
- match csv::collect(dec.decode::<P... | 4 | 33 | 56 |
a3c93707ed7062391a9044bb7ff4bc0017de565e | Andrew Gallant | 2014-11-06T22:28:32 | Add impls for Error and FromError traits. | diff --git a/src/lib.rs b/src/lib.rs
index 1ed9e37..f49f157 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -190,6 +190,8 @@ extern crate rand;
extern crate serialize;
extern crate "test" as stdtest;
+use std::error::Error as StdError;
+use std::error::FromError;
use std::fmt;
use std::io;
@@ -265,8 +267,8 @@ pub e... | 1 | 38 | 11 |
5de3afec6363933110b6358d0575c529860c2962 | Andrew Gallant | 2014-11-02T18:52:23 | Collection reform. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index d2482b0..a41abbe 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -62,6 +62,16 @@ impl ByteString {
pub fn as_utf8_string(self) -> Result<String, ByteString> {
String::from_utf8(self.into_bytes()).map_err(ByteString)
}
+
+ /// Return the number... | 2 | 17 | 12 |
af6e80bd40a299393fb07fded3fb013f634c6caf | Andrew Gallant | 2014-11-01T15:29:11 | Don't specify library type. | diff --git a/Cargo.toml b/Cargo.toml
index fd43553..d0914f3 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -5,6 +5,3 @@ authors = ["Andrew Gallant <jamslam@gmail.com>"]
[lib]
name = "csv"
-path = "src/lib.rs"
-crate_type = ["dylib", "rlib"]
- | 1 | 0 | 3 |
9feb53caa5a323d7c763ecb460c20eac6c472679 | Andrew Gallant | 2014-11-01T01:30:44 | Update to latest Rust. | diff --git a/src/bench.rs b/src/bench.rs
index 2ca7201..aca61ae 100644
--- a/src/bench.rs
+++ b/src/bench.rs
@@ -1,7 +1,6 @@
use std::fmt::Show;
-use std::io;
+use std::io::{mod, AsRefReader};
use std::io::Reader as IoReader;
-use std::io::Writer as IoWriter;
use stdtest::Bencher;
use Reader;
diff --git a/src/ind... | 4 | 4 | 4 |
0e84dcda71a4029bee39b4942b580e322a0d8677 | Michael Gehring | 2014-10-30T09:22:49 | fail! -> panic! | diff --git a/examples/nfl_plays.rs b/examples/nfl_plays.rs
index a3990f4..a5bbfa4 100644
--- a/examples/nfl_plays.rs
+++ b/examples/nfl_plays.rs
@@ -26,7 +26,7 @@ fn main() {
let mut dec = csv::Reader::from_file(fp);
match csv::collect(dec.decode::<Play>()) {
- Err(err) => fail!("{}", err),
+ ... | 5 | 16 | 16 |
e8945bf8a1e8779727748c2e0d460f8d9aaf4b67 | Andrew Gallant | 2014-10-19T05:11:21 | Fix an ordering bug.
This occurs when the CSV data has one row, the caller says it has no
headers and the caller asks for the headers before any calls to a
record iterator.
The correct behavior is that the iterator returns the first row (since
it isn't a header). But the previous behavior was that the iterator
return... | diff --git a/src/reader.rs b/src/reader.rs
index a1fd935..3568f1f 100644
--- a/src/reader.rs
+++ b/src/reader.rs
@@ -843,9 +843,11 @@ pub struct ByteRecords<'a, R: 'a> {
impl<'a, R: io::Reader> Iterator<CsvResult<Vec<ByteString>>>
for ByteRecords<'a, R> {
fn next(&mut self) -> Option<CsvResult<Vec<ByteString... | 2 | 17 | 4 |
97e4a399a49dcb565ebe7199240447428b190aec | Andrew Gallant | 2014-10-19T05:09:48 | Don't use the unsafe iterator in the benchmark.
(The unsafe iterator is my dirty little secret for now.) | diff --git a/bench/huge.rs b/bench/huge.rs
index b10795a..0be438e 100644
--- a/bench/huge.rs
+++ b/bench/huge.rs
@@ -6,6 +6,11 @@ fn main() {
let huge = "../examples/data/ss10pusa.csv";
let mut rdr = csv::Reader::from_file(&Path::new(huge));
while !rdr.done() {
- for field in rdr { let _ = field.u... | 1 | 6 | 1 |
842dd3bfecd31f33ec6cd76ed2c9d4f947f1a5e8 | Andrew Gallant | 2014-10-19T01:22:44 | Make `write` more general and get better code reuse.
I do not think this is a breaking change. | diff --git a/src/writer.rs b/src/writer.rs
index 88cacd6..d810d69 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -111,7 +111,8 @@ impl<W: io::Writer> Writer<W> {
/// That is, it writes a record of strings---no more and no less.
///
/// This method accepts an iterator of *fields* for a single record. E... | 1 | 12 | 45 |
93d7e4d2e097998eec727c26551ecd61727b660d | Andrew Gallant | 2014-10-19T01:22:09 | Indexed was reporting an incorrect count when headers are present. | diff --git a/src/index/mod.rs b/src/index/mod.rs
index c79774e..4515743 100644
--- a/src/index/mod.rs
+++ b/src/index/mod.rs
@@ -13,7 +13,10 @@ pub struct Indexed<R, I> {
impl<R: io::Reader + io::Seek, I: io::Reader + io::Seek> Indexed<R, I> {
pub fn new(rdr: Reader<R>, mut idx: I) -> CsvResult<Indexed<R, I>> {
... | 1 | 4 | 1 |
8281b0f125fea2ed2a2ceb12d4d920216c0883ea | Andrew Gallant | 2014-10-19T01:21:43 | FromIterator impl for ByteString | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 73fc590..d2482b0 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -125,3 +125,9 @@ impl<S: Str> Equiv<S> for ByteString {
impl Collection for ByteString {
fn len(&self) -> uint { self.as_bytes().len() }
}
+
+impl FromIterator<u8> for ByteString {
+ fn from... | 1 | 6 | 0 |
a4e9ca5769a674b126175ebe4ca878b522299383 | Andrew Gallant | 2014-10-16T21:04:44 | Define `IntoVector` to replace lost functionality in `CloneableVector`.
Fixes #5. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index c9ef284..73fc590 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -2,6 +2,20 @@ use std::fmt;
use std::hash;
use std::ops;
+/// A trait that encapsulates a `Vec<T>` or a `&[T]`.
+pub trait IntoVector<T> {
+ /// Convert the underlying value to a vector.
+ f... | 5 | 22 | 8 |
2f70641b3ae1c921b6536fca094359f01c6f7e5b | Andrew Gallant | 2014-10-09T00:32:32 | Update to work with latest Rust master. | diff --git a/src/bytestr.rs b/src/bytestr.rs
index 264a16b..c9ef284 100644
--- a/src/bytestr.rs
+++ b/src/bytestr.rs
@@ -66,7 +66,7 @@ impl fmt::Show for ByteString {
}
}
-impl Slice<u8> for ByteString {
+impl AsSlice<u8> for ByteString {
#[inline]
fn as_slice<'a>(&'a self) -> &'a [u8] {
let ... | 3 | 11 | 11 |
c28eed9ce951af4bac355d74f34d93eb66b6319f | Andrew Gallant | 2014-10-04T23:19:08 | Add the number of records to the index. | diff --git a/src/index/mod.rs b/src/index/mod.rs
index c22effe..c79774e 100644
--- a/src/index/mod.rs
+++ b/src/index/mod.rs
@@ -2,31 +2,43 @@
use std::io;
-use {CsvResult, ErrIo, Reader};
+use {CsvResult, ErrIo, ErrIndex, Reader};
pub struct Indexed<R, I> {
rdr: Reader<R>,
idx: I,
+ count: u64,
}... | 2 | 23 | 7 |
a1c041f554ab0717755fb2924854a7d149a99490 | Andrew Gallant | 2014-10-04T17:44:24 | Shorten name. | diff --git a/src/writer.rs b/src/writer.rs
index 4f0105f..05e83ec 100644
--- a/src/writer.rs
+++ b/src/writer.rs
@@ -205,8 +205,8 @@ impl<W: io::Writer> Writer<W> {
}
#[doc(hidden)]
- pub fn write_result_bytes<S: Slice<u8>, I: Iterator<CsvResult<S>>>
- (&mut self, r: I) -> Csv... | 1 | 2 | 2 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.