diff options
| author | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-03-10 21:15:29 +0100 |
|---|---|---|
| committer | Ulrik Sverdrup <bluss@users.noreply.github.com> | 2016-03-13 09:36:02 +0100 |
| commit | ec39a76a3e8a96563845eca4eb77f3ba2a2090a9 (patch) | |
| tree | 10fc0d1b022ede0b316b7cbef7d1adf5730ccf40 | |
| parent | 3e05371c13f851a5af57a96a5e13c99537787314 (diff) | |
| download | rust-ec39a76a3e8a96563845eca4eb77f3ba2a2090a9.tar.gz rust-ec39a76a3e8a96563845eca4eb77f3ba2a2090a9.zip | |
Call str::to_owned in String::from and uninline it
String::from does not need to be inlined, it can be without it just like str::to_owned and String::clone are.
| -rw-r--r-- | src/libcollections/string.rs | 16 |
1 files changed, 2 insertions, 14 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index beb12ff58af..98225dd3dda 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -66,7 +66,7 @@ use core::str::pattern::Pattern; use rustc_unicode::char::{decode_utf16, REPLACEMENT_CHARACTER}; use rustc_unicode::str as unicode_str; -use borrow::Cow; +use borrow::{Cow, ToOwned}; use range::RangeArgument; use str::{self, FromStr, Utf8Error, Chars}; use vec::Vec; @@ -1797,20 +1797,8 @@ impl AsRef<[u8]> for String { #[stable(feature = "rust1", since = "1.0.0")] impl<'a> From<&'a str> for String { - #[cfg(not(test))] - #[inline] fn from(s: &'a str) -> String { - String { vec: <[_]>::to_vec(s.as_bytes()) } - } - - // HACK(japaric): with cfg(test) the inherent `[T]::to_vec` method, which is - // required for this method definition, is not available. Since we don't - // require this method for testing purposes, I'll just stub it - // NB see the slice::hack module in slice.rs for more information - #[inline] - #[cfg(test)] - fn from(_: &str) -> String { - panic!("not available with cfg(test)"); + s.to_owned() } } |
