diff options
| author | bors <bors@rust-lang.org> | 2014-07-08 20:06:40 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2014-07-08 20:06:40 +0000 |
| commit | 8bb34a3146e6ba4bc7902a85de90cf4f8064ace0 (patch) | |
| tree | f5dd9ae1066eb755649fcced85e998d72147de19 /src/libdebug | |
| parent | 35e21346216cc4c5a3b22bb6fb316f8c867f8c92 (diff) | |
| parent | 12c334a77b897f7b1cb6cff3c56a71ecb89c82af (diff) | |
| download | rust-8bb34a3146e6ba4bc7902a85de90cf4f8064ace0.tar.gz rust-8bb34a3146e6ba4bc7902a85de90cf4f8064ace0.zip | |
auto merge of #15493 : brson/rust/tostr, r=pcwalton
This updates https://github.com/rust-lang/rust/pull/15075. Rename `ToStr::to_str` to `ToString::to_string`. The naive renaming ends up with two `to_string` functions defined on strings in the prelude (the other defined via `collections::str::StrAllocating`). To remedy this I removed `StrAllocating::to_string`, making all conversions from `&str` to `String` go through `Show`. This has a measurable impact on the speed of this conversion, but the sense I get from others is that it's best to go ahead and unify `to_string` and address performance for all `to_string` conversions in `core::fmt`. `String::from_str(...)` still works as a manual fast-path. Note that the patch was done with a script, and ended up renaming a number of other `*_to_str` functions, particularly inside of rustc. All the ones I saw looked correct, and I didn't notice any additional API breakage. Closes #15046.
Diffstat (limited to 'src/libdebug')
| -rw-r--r-- | src/libdebug/fmt.rs | 2 | ||||
| -rw-r--r-- | src/libdebug/repr.rs | 4 |
2 files changed, 3 insertions, 3 deletions
diff --git a/src/libdebug/fmt.rs b/src/libdebug/fmt.rs index 4087cb95271..0b04a07ea88 100644 --- a/src/libdebug/fmt.rs +++ b/src/libdebug/fmt.rs @@ -45,7 +45,7 @@ impl<T> Poly for T { // If we have a specified width for formatting, then we have to make // this allocation of a new string _ => { - let s = repr::repr_to_str(self); + let s = repr::repr_to_string(self); f.pad(s.as_slice()) } } diff --git a/src/libdebug/repr.rs b/src/libdebug/repr.rs index 133353ec3d7..3e541929dbf 100644 --- a/src/libdebug/repr.rs +++ b/src/libdebug/repr.rs @@ -73,7 +73,7 @@ int_repr!(u64, "u64") macro_rules! num_repr(($ty:ident, $suffix:expr) => (impl Repr for $ty { fn write_repr(&self, writer: &mut io::Writer) -> io::IoResult<()> { - let s = self.to_str(); + let s = self.to_string(); writer.write(s.as_bytes()).and_then(|()| { writer.write($suffix) }) @@ -564,7 +564,7 @@ pub fn write_repr<T>(writer: &mut io::Writer, object: &T) -> io::IoResult<()> { } } -pub fn repr_to_str<T>(t: &T) -> String { +pub fn repr_to_string<T>(t: &T) -> String { let mut result = io::MemWriter::new(); write_repr(&mut result as &mut io::Writer, t).unwrap(); String::from_utf8(result.unwrap()).unwrap() |
