Skip to content

Commit 12c334a

Browse files
richobrson
authored andcommitted
std: Rename the ToStr trait to ToString, and to_str to to_string.
[breaking-change]
1 parent bfe4ddf commit 12c334a

File tree

208 files changed

+1557
-1390
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

208 files changed

+1557
-1390
lines changed

src/compiletest/compiletest.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,7 @@ pub fn log_config(config: &Config) {
187187
opt_str(&config.filter
188188
.as_ref()
189189
.map(|re| {
190-
re.to_str().into_string()
190+
re.to_string().into_string()
191191
}))));
192192
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
193193
logv(c, format!("host-rustcflags: {}",

src/compiletest/errors.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
3131
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
3232
re.captures(line).and_then(|caps| {
3333
let adjusts = caps.name("adjusts").len();
34-
let kind = caps.name("kind").to_ascii().to_lower().into_str();
34+
let kind = caps.name("kind").to_ascii().to_lower().into_string();
3535
let msg = caps.name("msg").trim().to_string();
3636

3737
debug!("line={} kind={} msg={}", line_num, kind, msg);

src/compiletest/util.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub fn make_new_path(path: &str) -> String {
4141
Some(curr) => {
4242
format!("{}{}{}", path, path_div(), curr)
4343
}
44-
None => path.to_str()
44+
None => path.to_string()
4545
}
4646
}
4747

src/doc/guide-tasks.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -465,7 +465,7 @@ fn stringifier(channel: &DuplexStream<String, uint>) {
465465
let mut value: uint;
466466
loop {
467467
value = channel.recv();
468-
channel.send(value.to_str());
468+
channel.send(value.to_string());
469469
if value == 0 { break; }
470470
}
471471
}
@@ -478,7 +478,7 @@ send strings (the first type parameter) and receive `uint` messages
478478
(the second type parameter). The body itself simply loops, reading
479479
from the channel and then sending its response back. The actual
480480
response itself is simply the stringified version of the received value,
481-
`uint::to_str(value)`.
481+
`uint::to_string(value)`.
482482

483483
Here is the code for the parent task:
484484

@@ -492,7 +492,7 @@ use std::comm::duplex;
492492
# let mut value: uint;
493493
# loop {
494494
# value = channel.recv();
495-
# channel.send(value.to_str());
495+
# channel.send(value.to_string());
496496
# if value == 0u { break; }
497497
# }
498498
# }

src/doc/po/ja/complement-cheatsheet.md.po

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ msgstr ""
2323
#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
2424
#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
2525
msgid ""
26-
"Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr."
26+
"Use [`ToString`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToString."
2727
"html)."
2828
msgstr ""
2929
"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
@@ -34,7 +34,7 @@ msgstr ""
3434
#, fuzzy
3535
#| msgid ""
3636
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
37-
msgid "~~~ let x: int = 42; let y: String = x.to_str(); ~~~"
37+
msgid "~~~ let x: int = 42; let y: String = x.to_string(); ~~~"
3838
msgstr ""
3939
"~~~~\n"
4040
"let x: f64 = 4.0;\n"

src/doc/po/ja/rust.md.po

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1656,7 +1656,7 @@ msgstr ""
16561656
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
16571657
msgid ""
16581658
"impl Printable for int {\n"
1659-
" fn to_string(&self) -> String { self.to_str() }\n"
1659+
" fn to_string(&self) -> String { self.to_string() }\n"
16601660
"}\n"
16611661
msgstr ""
16621662
"~~~~ {.ignore}\n"

src/doc/po/ja/tutorial.md.po

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4410,9 +4410,9 @@ msgstr ""
44104410

44114411
#. type: Plain text
44124412
#: src/doc/tutorial.md:2528
4413-
msgid "#[deriving(Rand, ToStr)] enum ABC { A, B, C } ~~~"
4413+
msgid "#[deriving(Rand, ToString)] enum ABC { A, B, C } ~~~"
44144414
msgstr ""
4415-
"#[deriving(Rand, ToStr)]\n"
4415+
"#[deriving(Rand, ToString)]\n"
44164416
"enum ABC { A, B, C }\n"
44174417
"~~~"
44184418

@@ -4422,15 +4422,15 @@ msgstr ""
44224422
#| msgid ""
44234423
#| "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
44244424
#| "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
4425-
#| "`Zero`, and `ToStr`."
4425+
#| "`Zero`, and `ToString`."
44264426
msgid ""
44274427
"The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
44284428
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
4429-
"`Default`, `Zero`, and `ToStr`."
4429+
"`Default`, `Zero`, and `ToString`."
44304430
msgstr ""
44314431
"実装を自動的に導出可能なトレイトは、 `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
44324432
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, `Zero`, "
4433-
"および `ToStr` です。."
4433+
"および `ToString` です。."
44344434

44354435
#. type: Plain text
44364436
#: src/doc/tutorial.md:2534

src/doc/rust.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3671,15 +3671,15 @@ An example of an object type:
36713671

36723672
~~~~
36733673
trait Printable {
3674-
fn to_string(&self) -> String;
3674+
fn stringify(&self) -> String;
36753675
}
36763676
36773677
impl Printable for int {
3678-
fn to_string(&self) -> String { self.to_str() }
3678+
fn stringify(&self) -> String { self.to_string() }
36793679
}
36803680
36813681
fn print(a: Box<Printable>) {
3682-
println!("{}", a.to_string());
3682+
println!("{}", a.stringify());
36833683
}
36843684
36853685
fn main() {

src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,7 @@ syn keyword rustTrait RawPtr
100100
syn keyword rustTrait Buffer Writer Reader Seek
101101
syn keyword rustTrait Str StrVector StrSlice OwnedStr
102102
syn keyword rustTrait IntoMaybeOwned StrAllocating
103-
syn keyword rustTrait ToStr IntoStr
103+
syn keyword rustTrait ToString IntoStr
104104
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
105105
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
106106
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12

src/libcollections/bitv.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -60,17 +60,17 @@ enum BitvVariant { Big(BigBitv), Small(SmallBitv) }
6060
/// bv.set(3, true);
6161
/// bv.set(5, true);
6262
/// bv.set(7, true);
63-
/// println!("{}", bv.to_str());
63+
/// println!("{}", bv.to_string());
6464
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
6565
///
6666
/// // flip all values in bitvector, producing non-primes less than 10
6767
/// bv.negate();
68-
/// println!("{}", bv.to_str());
68+
/// println!("{}", bv.to_string());
6969
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
7070
///
7171
/// // reset bitvector to empty
7272
/// bv.clear();
73-
/// println!("{}", bv.to_str());
73+
/// println!("{}", bv.to_string());
7474
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
7575
/// ```
7676
pub struct Bitv {
@@ -996,10 +996,10 @@ mod tests {
996996
#[test]
997997
fn test_to_str() {
998998
let zerolen = Bitv::new();
999-
assert_eq!(zerolen.to_str().as_slice(), "");
999+
assert_eq!(zerolen.to_string().as_slice(), "");
10001000

10011001
let eightbits = Bitv::with_capacity(8u, false);
1002-
assert_eq!(eightbits.to_str().as_slice(), "00000000")
1002+
assert_eq!(eightbits.to_string().as_slice(), "00000000")
10031003
}
10041004

10051005
#[test]
@@ -1022,7 +1022,7 @@ mod tests {
10221022
let mut b = bitv::Bitv::with_capacity(2, false);
10231023
b.set(0, true);
10241024
b.set(1, false);
1025-
assert_eq!(b.to_str().as_slice(), "10");
1025+
assert_eq!(b.to_string().as_slice(), "10");
10261026
}
10271027

10281028
#[test]
@@ -1333,7 +1333,7 @@ mod tests {
13331333
fn test_from_bytes() {
13341334
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
13351335
let str = format!("{}{}{}", "10110110", "00000000", "11111111");
1336-
assert_eq!(bitv.to_str().as_slice(), str.as_slice());
1336+
assert_eq!(bitv.to_string().as_slice(), str.as_slice());
13371337
}
13381338

13391339
#[test]
@@ -1352,7 +1352,7 @@ mod tests {
13521352
fn test_from_bools() {
13531353
let bools = vec![true, false, true, true];
13541354
let bitv: Bitv = bools.iter().map(|n| *n).collect();
1355-
assert_eq!(bitv.to_str().as_slice(), "1011");
1355+
assert_eq!(bitv.to_string().as_slice(), "1011");
13561356
}
13571357

13581358
#[test]
@@ -1787,7 +1787,7 @@ mod tests {
17871787
s.insert(10);
17881788
s.insert(50);
17891789
s.insert(2);
1790-
assert_eq!("{1, 2, 10, 50}".to_string(), s.to_str());
1790+
assert_eq!("{1, 2, 10, 50}".to_string(), s.to_string());
17911791
}
17921792

17931793
fn rng() -> rand::IsaacRng {

src/libcollections/btree.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -787,7 +787,6 @@ mod test_btree {
787787
fn insert_test_one() {
788788
let b = BTree::new(1i, "abc".to_string(), 2);
789789
let is_insert = b.insert(2i, "xyz".to_string());
790-
//println!("{}", is_insert.clone().to_str());
791790
assert!(is_insert.root.is_leaf());
792791
}
793792

@@ -798,7 +797,7 @@ mod test_btree {
798797
let leaf_elt_3 = LeafElt::new(3i, "ccc".to_string());
799798
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3));
800799
let b = BTree::new_with_node_len(n, 3, 2);
801-
//println!("{}", b.clone().insert(4, "ddd".to_string()).to_str());
800+
//println!("{}", b.clone().insert(4, "ddd".to_string()).to_string());
802801
assert!(b.insert(4, "ddd".to_string()).root.is_leaf());
803802
}
804803

@@ -810,7 +809,7 @@ mod test_btree {
810809
let leaf_elt_4 = LeafElt::new(4i, "ddd".to_string());
811810
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
812811
let b = BTree::new_with_node_len(n, 3, 2);
813-
//println!("{}", b.clone().insert(5, "eee".to_string()).to_str());
812+
//println!("{}", b.clone().insert(5, "eee".to_string()).to_string());
814813
assert!(!b.insert(5, "eee".to_string()).root.is_leaf());
815814
}
816815

@@ -827,7 +826,7 @@ mod test_btree {
827826
b = b.clone().insert(7, "ggg".to_string());
828827
b = b.clone().insert(8, "hhh".to_string());
829828
b = b.clone().insert(0, "omg".to_string());
830-
//println!("{}", b.clone().to_str());
829+
//println!("{}", b.clone().to_string());
831830
assert!(!b.root.is_leaf());
832831
}
833832

@@ -905,11 +904,11 @@ mod test_btree {
905904
assert!(&b2.cmp(&b) == &Greater)
906905
}
907906

908-
//Tests the BTree's to_str() method.
907+
//Tests the BTree's to_string() method.
909908
#[test]
910909
fn btree_tostr_test() {
911910
let b = BTree::new(1i, "abc".to_string(), 2);
912-
assert_eq!(b.to_str(), "Key: 1, value: abc;".to_string())
911+
assert_eq!(b.to_string(), "Key: 1, value: abc;".to_string())
913912
}
914913

915914
}

src/libcollections/dlist.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1041,12 +1041,12 @@ mod tests {
10411041
#[test]
10421042
fn test_show() {
10431043
let list: DList<int> = range(0i, 10).collect();
1044-
assert!(list.to_str().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
1044+
assert!(list.to_string().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
10451045

10461046
let list: DList<&str> = vec!["just", "one", "test", "more"].iter()
10471047
.map(|&s| s)
10481048
.collect();
1049-
assert!(list.to_str().as_slice() == "[just, one, test, more]");
1049+
assert!(list.to_string().as_slice() == "[just, one, test, more]");
10501050
}
10511051

10521052
#[cfg(test)]

src/libcollections/smallintmap.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -491,7 +491,7 @@ mod test_map {
491491
map.insert(1, 2i);
492492
map.insert(3, 4i);
493493

494-
let map_str = map.to_str();
494+
let map_str = map.to_string();
495495
let map_str = map_str.as_slice();
496496
assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
497497
assert_eq!(format!("{}", empty), "{}".to_string());

0 commit comments

Comments
 (0)