diff options
| author | bors <bors@rust-lang.org> | 2013-12-04 11:32:23 -0800 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2013-12-04 11:32:23 -0800 |
| commit | 9b9cf9892b74dc376fe740ea56858042e9bd89de (patch) | |
| tree | 0453cef98715b1efed5b3baed3d0481eb474f09c /src/libextra | |
| parent | 5fa6bd526ef66ce9ce80e975340aa98bcc3596b7 (diff) | |
| parent | b0426edc0a83699de79ceffcbe603812b9b53374 (diff) | |
| download | rust-9b9cf9892b74dc376fe740ea56858042e9bd89de.tar.gz rust-9b9cf9892b74dc376fe740ea56858042e9bd89de.zip | |
auto merge of #10701 : huonw/rust/rm-from_utf8, r=brson
This function had type &[u8] -> ~str, i.e. it allocates a string internally, even though the non-allocating version that take &[u8] -> &str and ~[u8] -> ~str are all that is necessary in most circumstances.
Diffstat (limited to 'src/libextra')
| -rw-r--r-- | src/libextra/base64.rs | 4 | ||||
| -rw-r--r-- | src/libextra/ebml.rs | 2 | ||||
| -rw-r--r-- | src/libextra/hex.rs | 4 | ||||
| -rw-r--r-- | src/libextra/terminfo/parser/compiled.rs | 4 | ||||
| -rw-r--r-- | src/libextra/uuid.rs | 2 | ||||
| -rw-r--r-- | src/libextra/workcache.rs | 2 |
6 files changed, 10 insertions, 8 deletions
diff --git a/src/libextra/base64.rs b/src/libextra/base64.rs index 94e3917a7ec..c4247799cad 100644 --- a/src/libextra/base64.rs +++ b/src/libextra/base64.rs @@ -162,7 +162,7 @@ impl<'self> FromBase64 for &'self str { * Convert any base64 encoded string (literal, `@`, `&`, or `~`) * to the byte values it encodes. * - * You can use the `from_utf8` function in `std::str` + * You can use the `from_utf8_owned` function in `std::str` * to turn a `[u8]` into a string with characters corresponding to those * values. * @@ -180,7 +180,7 @@ impl<'self> FromBase64 for &'self str { * println!("base64 output: {}", hello_str); * let res = hello_str.from_base64(); * if res.is_ok() { - * let optBytes = str::from_utf8_opt(res.unwrap()); + * let optBytes = str::from_utf8_owned_opt(res.unwrap()); * if optBytes.is_some() { * println!("decoded from base64: {}", optBytes.unwrap()); * } diff --git a/src/libextra/ebml.rs b/src/libextra/ebml.rs index 19959dd2705..aadb93f2e24 100644 --- a/src/libextra/ebml.rs +++ b/src/libextra/ebml.rs @@ -41,7 +41,7 @@ impl Doc { } pub fn as_str_slice<'a>(&'a self) -> &'a str { - str::from_utf8_slice(self.data.slice(self.start, self.end)) + str::from_utf8(self.data.slice(self.start, self.end)) } pub fn as_str(&self) -> ~str { diff --git a/src/libextra/hex.rs b/src/libextra/hex.rs index 5a1d1308f8c..7daba4c08f2 100644 --- a/src/libextra/hex.rs +++ b/src/libextra/hex.rs @@ -62,7 +62,7 @@ impl<'self> FromHex for &'self str { * Convert any hexadecimal encoded string (literal, `@`, `&`, or `~`) * to the byte values it encodes. * - * You can use the `from_utf8` function in `std::str` + * You can use the `from_utf8_owned` function in `std::str` * to turn a `[u8]` into a string with characters corresponding to those * values. * @@ -80,7 +80,7 @@ impl<'self> FromHex for &'self str { * println!("{}", hello_str); * let bytes = hello_str.from_hex().unwrap(); * println!("{:?}", bytes); - * let result_str = str::from_utf8(bytes); + * let result_str = str::from_utf8_owned(bytes); * println!("{}", result_str); * } * ``` diff --git a/src/libextra/terminfo/parser/compiled.rs b/src/libextra/terminfo/parser/compiled.rs index af1532db935..bc997c5147d 100644 --- a/src/libextra/terminfo/parser/compiled.rs +++ b/src/libextra/terminfo/parser/compiled.rs @@ -215,7 +215,9 @@ pub fn parse(file: &mut io::Reader, return Err(~"incompatible file: more string offsets than expected"); } - let names_str = str::from_utf8(file.read_bytes(names_bytes as uint - 1)); // don't read NUL + // don't read NUL + let names_str = str::from_utf8_owned(file.read_bytes(names_bytes as uint - 1)); + let term_names: ~[~str] = names_str.split('|').map(|s| s.to_owned()).collect(); file.read_byte(); // consume NUL diff --git a/src/libextra/uuid.rs b/src/libextra/uuid.rs index d40eef732f1..0fbac7771dc 100644 --- a/src/libextra/uuid.rs +++ b/src/libextra/uuid.rs @@ -310,7 +310,7 @@ impl Uuid { s[i*2+0] = digit[0]; s[i*2+1] = digit[1]; } - str::from_utf8(s) + str::from_utf8_owned(s) } /// Returns a string of hexadecimal digits, separated into groups with a hypen diff --git a/src/libextra/workcache.rs b/src/libextra/workcache.rs index ab36defe522..d906896ff60 100644 --- a/src/libextra/workcache.rs +++ b/src/libextra/workcache.rs @@ -260,7 +260,7 @@ fn json_encode<'self, T:Encodable<json::Encoder<'self>>>(t: &T) -> ~str { let mut writer = MemWriter::new(); let mut encoder = json::Encoder::init(&mut writer as &mut io::Writer); t.encode(&mut encoder); - str::from_utf8(writer.inner_ref().as_slice()) + str::from_utf8_owned(writer.inner()) } // FIXME(#5121) |
