Skip to content

Commit

Permalink
Convert all ~str to StrBuf
Browse files Browse the repository at this point in the history
  • Loading branch information
BurntSushi committed May 25, 2014
1 parent eeffeaf commit 45812dc
Show file tree
Hide file tree
Showing 9 changed files with 153 additions and 152 deletions.
4 changes: 2 additions & 2 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ ctags:

docs:
rm -rf doc
rustdoc --test src/lib.rs
rustdoc -L . --test src/lib.rs
rustdoc src/lib.rs
# WTF is rustdoc doing?
chmod 755 doc
Expand All @@ -37,7 +37,7 @@ test-clean:
rm -rf ./test-runner ./bench-runner

clean: test-clean
rm -f *.rlib
rm -f *.rlib *.so

push:
git push origin master
Expand Down
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ fn main() {
let fp = &Path::new("./data/simple.csv");
let mut rdr = csv::Decoder::from_file(fp);

for (s1, s2, dist) in rdr.decode_iter::<(~str, ~str, uint)>() {
for (s1, s2, dist) in rdr.decode_iter::<(StrBuf, StrBuf, uint)>() {
println!("({}, {}): {}", s1, s2, dist);
}
}
Expand All @@ -39,8 +39,8 @@ use std::path::Path;

#[deriving(Decodable)]
struct Record {
s1: ~str,
s2: ~str,
s1: StrBuf,
s2: StrBuf,
dist: uint,
}

Expand All @@ -59,8 +59,8 @@ Do some records not have a distance for some reason? Use an `Option` type!
```rust
#[deriving(Decodable)]
struct Record {
s1: ~str,
s2: ~str,
s1: StrBuf,
s2: StrBuf,
dist: Option<uint>,
}
```
Expand Down
1 change: 1 addition & 0 deletions examples/data/2012_nfl_pbp_data.csv
14 changes: 7 additions & 7 deletions examples/nfl_plays.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,16 +6,16 @@ use csv::Decoder;

#[deriving(Decodable)]
struct Play {
gameid: ~str,
gameid: StrBuf,
qtr: uint,
min: Option<uint>,
sec: Option<uint>,
team_off: ~str,
team_def: ~str,
team_off: StrBuf,
team_def: StrBuf,
down: Option<uint>,
togo: Option<uint>,
ydline: Option<uint>,
description: ~str,
description: StrBuf,
offscore: uint,
defscore: uint,
season: uint,
Expand All @@ -32,9 +32,9 @@ fn main() {
println!("Found {} plays.", plays.len());

let tfb = plays.iter().find(|&p| {
"NE" == p.team_off && "DEN" == p.team_def
&& p.description.contains("TOUCHDOWN")
&& p.description.contains("T.Brady")
"NE" == p.team_off.as_slice() && "DEN" == p.team_def.as_slice()
&& p.description.as_slice().contains("TOUCHDOWN")
&& p.description.as_slice().contains("T.Brady")
}).unwrap();
println!("Tom Brady touchdown: {}", tfb.description);
}
Expand Down
2 changes: 1 addition & 1 deletion examples/simple.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ fn main() {
let fp = &Path::new("./data/simple.csv");
let mut rdr = csv::Decoder::from_file(fp);

for (s1, s2, dist) in rdr.decode_iter::<(~str, ~str, uint)>() {
for (s1, s2, dist) in rdr.decode_iter::<(StrBuf, StrBuf, uint)>() {
println!("({}, {}): {}", s1, s2, dist);
}
}
4 changes: 2 additions & 2 deletions examples/simple_missing.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::path::Path;

#[deriving(Decodable)]
struct Record {
s1: ~str,
s2: ~str,
s1: StrBuf,
s2: StrBuf,
dist: Option<uint>,
}

Expand Down
4 changes: 2 additions & 2 deletions examples/simple_struct.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ use std::path::Path;

#[deriving(Decodable)]
struct Record {
s1: ~str,
s2: ~str,
s1: StrBuf,
s2: StrBuf,
dist: uint,
}

Expand Down
2 changes: 1 addition & 1 deletion examples/test
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
set -e

for f in *.rs; do
rustc "$f"
rustc -L.. "$f"
./${f%%.rs}
rm -f ${f%%.rs}
done
Expand Down

0 comments on commit 45812dc

Please sign in to comment.