Skip to content

Str -> String #15075

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions RELEASES.txt
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,7 @@ Version 0.10 (April 2014)
`slice::last()`) now return `Option<T>` instead of `T` + failing.
* std: `fmt::Default` has been renamed to `fmt::Show`, and it now has a new
deriving mode: `#[deriving(Show)]`.
* std: `ToStr` is now implemented for all types implementing `Show`.
* std: `ToString` is now implemented for all types implementing `Show`.
* std: The formatting trait methods now take `&self` instead of `&T`
* std: The `invert()` method on iterators has been renamed to `rev()`
* std: `std::num` has seen a reduction in the genericity of its traits,
Expand Down Expand Up @@ -528,7 +528,7 @@ Version 0.7 (July 2013)
* `fail!` and `assert!` accept `~str`, `&'static str` or `fmt!`-style
argument list.
* `Encodable`, `Decodable`, `Ord`, `TotalOrd`, `TotalEq`, `DeepClone`,
`Rand`, `Zero` and `ToStr` can all be automatically derived with
`Rand`, `Zero` and `ToString` can all be automatically derived with
`#[deriving(...)]`.
* The `bytes!` macro returns a vector of bytes for string, u8, char,
and unsuffixed integer literals.
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/compiletest.rs
Original file line number Diff line number Diff line change
Expand Up @@ -200,7 +200,7 @@ pub fn log_config(config: &Config) {
opt_str(&config.filter
.as_ref()
.map(|re| {
re.to_str().into_string()
re.to_string().into_string()
}))));
logv(c, format!("runtool: {}", opt_str(&config.runtool)));
logv(c, format!("host-rustcflags: {}",
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/errors.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ pub fn load_errors(re: &Regex, testfile: &Path) -> Vec<ExpectedError> {
fn parse_expected(line_num: uint, line: &str, re: &Regex) -> Option<ExpectedError> {
re.captures(line).and_then(|caps| {
let adjusts = caps.name("adjusts").len();
let kind = caps.name("kind").to_ascii().to_lower().into_str();
let kind = caps.name("kind").to_ascii().to_lower().into_string();
let msg = caps.name("msg").trim().to_string();

debug!("line={} kind={} msg={}", line_num, kind, msg);
Expand Down
2 changes: 1 addition & 1 deletion src/compiletest/util.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub fn make_new_path(path: &str) -> String {
Some(curr) => {
format!("{}{}{}", path, path_div(), curr)
}
None => path.to_str()
None => path.to_string()
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/doc/complement-cheatsheet.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,11 @@

**Int to string**

Use [`ToStr`](std/to_str/trait.ToStr.html).
Use [`ToString`](std/to_str/trait.ToString.html).

~~~
let x: int = 42;
let y: String = x.to_str();
let y: String = x.to_string();
~~~

**String to int**
Expand Down
6 changes: 3 additions & 3 deletions src/doc/guide-tasks.md
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,7 @@ fn stringifier(channel: &DuplexStream<String, uint>) {
let mut value: uint;
loop {
value = channel.recv();
channel.send(value.to_str());
channel.send(value.to_string());
if value == 0 { break; }
}
}
Expand All @@ -476,7 +476,7 @@ send strings (the first type parameter) and receive `uint` messages
(the second type parameter). The body itself simply loops, reading
from the channel and then sending its response back. The actual
response itself is simply the stringified version of the received value,
`uint::to_str(value)`.
`uint::to_string(value)`.

Here is the code for the parent task:

Expand All @@ -488,7 +488,7 @@ use std::comm::duplex;
# let mut value: uint;
# loop {
# value = channel.recv();
# channel.send(value.to_str());
# channel.send(value.to_string());
# if value == 0u { break; }
# }
# }
Expand Down
10 changes: 5 additions & 5 deletions src/doc/po/ja/complement-cheatsheet.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ msgstr ""
#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`ToStr`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToStr."
"Use [`ToString`](http://static.rust-lang.org/doc/master/std/to_str/trait.ToString."
"html)."
msgstr ""
"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
Expand All @@ -34,7 +34,7 @@ msgstr ""
#, fuzzy
#| msgid ""
#| "~~~~ let x: f64 = 4.0; let y: uint = x as uint; assert!(y == 4u); ~~~~"
msgid "~~~ let x: int = 42; let y: String = x.to_str(); ~~~"
msgid "~~~ let x: int = 42; let y: String = x.to_string(); ~~~"
msgstr ""
"~~~~\n"
"let x: f64 = 4.0;\n"
Expand Down Expand Up @@ -76,8 +76,8 @@ msgstr ""
#| "[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz [win-exe]: "
#| "http://static.rust-lang.org/dist/rust-nightly-install.exe"
msgid ""
"Use [`ToStrRadix`](http://static.rust-lang.org/doc/master/std/num/trait."
"ToStrRadix.html)."
"Use [`ToStringRadix`](http://static.rust-lang.org/doc/master/std/num/trait."
"ToStringRadix.html)."
msgstr ""
"[tarball]: http://static.rust-lang.org/dist/rust-nightly.tar.gz\n"
"[win-exe]: http://static.rust-lang.org/dist/rust-nightly-install.exe"
Expand All @@ -86,7 +86,7 @@ msgstr ""
#: src/doc/complement-cheatsheet.md:29
#, fuzzy
#| msgid "~~~~ use std::task::spawn;"
msgid "~~~ use std::num::ToStrRadix;"
msgid "~~~ use std::num::ToStringRadix;"
msgstr ""
"~~~~\n"
"use std::task::spawn;"
Expand Down
2 changes: 1 addition & 1 deletion src/doc/po/ja/rust.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -1656,7 +1656,7 @@ msgstr ""
#| msgid "~~~~ {.ignore} // main.rs extern crate world; fn main() { println(~\"hello \" + world::explore()); } ~~~~"
msgid ""
"impl Printable for int {\n"
" fn to_string(&self) -> String { self.to_str() }\n"
" fn to_string(&self) -> String { self.to_string() }\n"
"}\n"
msgstr ""
"~~~~ {.ignore}\n"
Expand Down
10 changes: 5 additions & 5 deletions src/doc/po/ja/tutorial.md.po
Original file line number Diff line number Diff line change
Expand Up @@ -4410,9 +4410,9 @@ msgstr ""

#. type: Plain text
#: src/doc/tutorial.md:2528
msgid "#[deriving(Rand, ToStr)] enum ABC { A, B, C } ~~~"
msgid "#[deriving(Rand, ToString)] enum ABC { A, B, C } ~~~"
msgstr ""
"#[deriving(Rand, ToStr)]\n"
"#[deriving(Rand, ToString)]\n"
"enum ABC { A, B, C }\n"
"~~~"

Expand All @@ -4422,15 +4422,15 @@ msgstr ""
#| msgid ""
#| "The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
#| "`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
#| "`Zero`, and `ToStr`."
#| "`Zero`, and `ToString`."
msgid ""
"The full list of derivable traits is `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, "
"`Default`, `Zero`, and `ToStr`."
"`Default`, `Zero`, and `ToString`."
msgstr ""
"実装を自動的に導出可能なトレイトは、 `Eq`, `TotalEq`, `Ord`, `TotalOrd`, "
"`Encodable` `Decodable`, `Clone`, `DeepClone`, `Hash`, `Rand`, `Zero`, "
"および `ToStr` です。."
"および `ToString` です。."

#. type: Plain text
#: src/doc/tutorial.md:2534
Expand Down
2 changes: 1 addition & 1 deletion src/doc/rust.md
Original file line number Diff line number Diff line change
Expand Up @@ -3676,7 +3676,7 @@ trait Printable {
}

impl Printable for int {
fn to_string(&self) -> String { self.to_str() }
fn to_string(&self) -> String { self.to_string() }
}

fn print(a: Box<Printable>) {
Expand Down
2 changes: 1 addition & 1 deletion src/etc/vim/syntax/rust.vim
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ syn keyword rustTrait RawPtr
syn keyword rustTrait Buffer Writer Reader Seek
syn keyword rustTrait Str StrVector StrSlice OwnedStr IntoMaybeOwned
syn keyword rustTrait StrAllocating
syn keyword rustTrait ToStr IntoStr
syn keyword rustTrait ToString IntoStr
syn keyword rustTrait Tuple1 Tuple2 Tuple3 Tuple4
syn keyword rustTrait Tuple5 Tuple6 Tuple7 Tuple8
syn keyword rustTrait Tuple9 Tuple10 Tuple11 Tuple12
Expand Down
20 changes: 10 additions & 10 deletions src/libcollections/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -243,17 +243,17 @@ enum Op {Union, Intersect, Assign, Difference}
/// bv.set(3, true);
/// bv.set(5, true);
/// bv.set(7, true);
/// println!("{}", bv.to_str());
/// println!("{}", bv.to_string());
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // flip all values in bitvector, producing non-primes less than 10
/// bv.negate();
/// println!("{}", bv.to_str());
/// println!("{}", bv.to_string());
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
///
/// // reset bitvector to empty
/// bv.clear();
/// println!("{}", bv.to_str());
/// println!("{}", bv.to_string());
/// println!("total bits set to true: {}", bv.iter().filter(|x| *x).count());
/// ```
#[deriving(Clone)]
Expand Down Expand Up @@ -1024,12 +1024,12 @@ mod tests {
static BENCH_BITS : uint = 1 << 14;

#[test]
fn test_to_str() {
fn test_to_string() {
let zerolen = Bitv::new(0u, false);
assert_eq!(zerolen.to_str().as_slice(), "");
assert_eq!(zerolen.to_string().as_slice(), "");

let eightbits = Bitv::new(8u, false);
assert_eq!(eightbits.to_str().as_slice(), "00000000")
assert_eq!(eightbits.to_string().as_slice(), "00000000")
}

#[test]
Expand All @@ -1052,7 +1052,7 @@ mod tests {
let mut b = bitv::Bitv::new(2, false);
b.set(0, true);
b.set(1, false);
assert_eq!(b.to_str().as_slice(), "10");
assert_eq!(b.to_string().as_slice(), "10");
}

#[test]
Expand Down Expand Up @@ -1363,7 +1363,7 @@ mod tests {
fn test_from_bytes() {
let bitv = from_bytes([0b10110110, 0b00000000, 0b11111111]);
let str = format!("{}{}{}", "10110110", "00000000", "11111111");
assert_eq!(bitv.to_str().as_slice(), str.as_slice());
assert_eq!(bitv.to_string().as_slice(), str.as_slice());
}

#[test]
Expand All @@ -1380,7 +1380,7 @@ mod tests {

#[test]
fn test_from_bools() {
assert!(from_bools([true, false, true, true]).to_str().as_slice() ==
assert!(from_bools([true, false, true, true]).to_string().as_slice() ==
"1011");
}

Expand Down Expand Up @@ -1674,7 +1674,7 @@ mod tests {
s.insert(10);
s.insert(50);
s.insert(2);
assert_eq!("{1, 2, 10, 50}".to_string(), s.to_str());
assert_eq!("{1, 2, 10, 50}".to_string(), s.to_string());
}

fn rng() -> rand::IsaacRng {
Expand Down
12 changes: 6 additions & 6 deletions src/libcollections/btree.rs
Original file line number Diff line number Diff line change
Expand Up @@ -787,7 +787,7 @@ mod test_btree {
fn insert_test_one() {
let b = BTree::new(1, "abc".to_string(), 2);
let is_insert = b.insert(2, "xyz".to_string());
//println!("{}", is_insert.clone().to_str());
//println!("{}", is_insert.clone().to_string());
assert!(is_insert.root.is_leaf());
}

Expand All @@ -798,7 +798,7 @@ mod test_btree {
let leaf_elt_3 = LeafElt::new(3, "ccc".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3));
let b = BTree::new_with_node_len(n, 3, 2);
//println!("{}", b.clone().insert(4, "ddd".to_string()).to_str());
//println!("{}", b.clone().insert(4, "ddd".to_string()).to_string());
assert!(b.insert(4, "ddd".to_string()).root.is_leaf());
}

Expand All @@ -810,7 +810,7 @@ mod test_btree {
let leaf_elt_4 = LeafElt::new(4, "ddd".to_string());
let n = Node::new_leaf(vec!(leaf_elt_1, leaf_elt_2, leaf_elt_3, leaf_elt_4));
let b = BTree::new_with_node_len(n, 3, 2);
//println!("{}", b.clone().insert(5, "eee".to_string()).to_str());
//println!("{}", b.clone().insert(5, "eee".to_string()).to_string());
assert!(!b.insert(5, "eee".to_string()).root.is_leaf());
}

Expand All @@ -827,7 +827,7 @@ mod test_btree {
b = b.clone().insert(7, "ggg".to_string());
b = b.clone().insert(8, "hhh".to_string());
b = b.clone().insert(0, "omg".to_string());
//println!("{}", b.clone().to_str());
//println!("{}", b.clone().to_string());
assert!(!b.root.is_leaf());
}

Expand Down Expand Up @@ -905,11 +905,11 @@ mod test_btree {
assert!(&b2.cmp(&b) == &Greater)
}

//Tests the BTree's to_str() method.
//Tests the BTree's to_string() method.
#[test]
fn btree_tostr_test() {
let b = BTree::new(1, "abc".to_string(), 2);
assert_eq!(b.to_str(), "Key: 1, value: abc;".to_string())
assert_eq!(b.to_string(), "Key: 1, value: abc;".to_string())
}

}
4 changes: 2 additions & 2 deletions src/libcollections/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1050,12 +1050,12 @@ mod tests {
#[test]
fn test_show() {
let list: DList<int> = range(0, 10).collect();
assert!(list.to_str().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");
assert!(list.to_string().as_slice() == "[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]");

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

#[cfg(test)]
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/hash/sip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -271,7 +271,7 @@ pub fn hash_with_keys<T: Hash<SipState>>(k0: u64, k1: u64, value: &T) -> u64 {
mod tests {
use test::Bencher;
use std::prelude::*;
use std::num::ToStrRadix;
use std::num::ToStringRadix;

use str::Str;
use string::String;
Expand Down
2 changes: 1 addition & 1 deletion src/libcollections/smallintmap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -491,7 +491,7 @@ mod test_map {
map.insert(1, 2);
map.insert(3, 4);

let map_str = map.to_str();
let map_str = map.to_string();
let map_str = map_str.as_slice();
assert!(map_str == "{1: 2, 3: 4}" || map_str == "{3: 4, 1: 2}");
assert_eq!(format!("{}", empty), "{}".to_string());
Expand Down
4 changes: 2 additions & 2 deletions src/libcollections/str.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2117,15 +2117,15 @@ mod tests {
let s = Slice("abcde");
assert_eq!(s.len(), 5);
assert_eq!(s.as_slice(), "abcde");
assert_eq!(s.to_str().as_slice(), "abcde");
assert_eq!(s.to_string().as_slice(), "abcde");
assert_eq!(format!("{}", s).as_slice(), "abcde");
assert!(s.lt(&Owned("bcdef".to_string())));
assert_eq!(Slice(""), Default::default());

let o = Owned("abcde".to_string());
assert_eq!(o.len(), 5);
assert_eq!(o.as_slice(), "abcde");
assert_eq!(o.to_str().as_slice(), "abcde");
assert_eq!(o.to_string().as_slice(), "abcde");
assert_eq!(format!("{}", o).as_slice(), "abcde");
assert!(o.lt(&Slice("bcdef")));
assert_eq!(Owned("".to_string()), Default::default());
Expand Down
6 changes: 3 additions & 3 deletions src/libcore/any.rs
Original file line number Diff line number Diff line change
Expand Up @@ -248,11 +248,11 @@ mod tests {

#[test]
fn test_show() {
use realstd::to_str::ToStr;
use realstd::to_str::ToString;
let a = box 8u as Box<::realstd::any::Any>;
let b = box Test as Box<::realstd::any::Any>;
let a_str = a.to_str();
let b_str = b.to_str();
let a_str = a.to_string();
let b_str = b.to_string();
assert_eq!(a_str.as_slice(), "Box<Any>");
assert_eq!(b_str.as_slice(), "Box<Any>");

Expand Down
6 changes: 3 additions & 3 deletions src/libcore/bool.rs
Original file line number Diff line number Diff line change
Expand Up @@ -100,10 +100,10 @@ mod tests {
}

#[test]
fn test_to_str() {
let s = false.to_str();
fn test_to_string() {
let s = false.to_string();
assert_eq!(s.as_slice(), "false");
let s = true.to_str();
let s = true.to_string();
assert_eq!(s.as_slice(), "true");
}

Expand Down
6 changes: 3 additions & 3 deletions src/libcore/char.rs
Original file line number Diff line number Diff line change
Expand Up @@ -769,9 +769,9 @@ mod test {
}

#[test]
fn test_to_str() {
use realstd::to_str::ToStr;
let s = 't'.to_str();
fn test_to_string() {
use realstd::to_str::ToString;
let s = 't'.to_string();
assert_eq!(s.as_slice(), "t");
}

Expand Down
Loading