diff options
| author | Esteban Küber <esteban@kuber.com.ar> | 2016-12-27 17:02:52 -0800 |
|---|---|---|
| committer | Esteban Küber <esteban@kuber.com.ar> | 2016-12-27 17:02:52 -0800 |
| commit | e766c465d2e4c4e3c106bfa8343cbe6f9192d445 (patch) | |
| tree | 821a7cf1e0b04ac9c0cddede6eb760bbf2d0ce62 /src/libcollections/string.rs | |
| parent | 96c52d4fd86aed6320732a511c04bcbfff7d117f (diff) | |
| parent | 314c28b729ae359b99586cc62c486c28e0d44424 (diff) | |
Merge branch 'master' into escape-reason-docs
Diffstat (limited to 'src/libcollections/string.rs')
| -rw-r--r-- | src/libcollections/string.rs | 10 |
1 files changed, 3 insertions, 7 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index b4c41a99a6b..157c762b4a7 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -542,11 +542,7 @@ impl String { unsafe { *xs.get_unchecked(i) } } fn safe_get(xs: &[u8], i: usize, total: usize) -> u8 { - if i >= total { - 0 - } else { - unsafe_get(xs, i) - } + if i >= total { 0 } else { unsafe_get(xs, i) } } let mut res = String::with_capacity(total); @@ -976,7 +972,7 @@ impl String { pub fn push(&mut self, ch: char) { match ch.len_utf8() { 1 => self.vec.push(ch as u8), - _ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0;4]).as_bytes()), + _ => self.vec.extend_from_slice(ch.encode_utf8(&mut [0; 4]).as_bytes()), } } @@ -1935,7 +1931,7 @@ impl<'a> FromIterator<String> for Cow<'a, str> { #[stable(feature = "from_string_for_vec_u8", since = "1.14.0")] impl From<String> for Vec<u8> { - fn from(string : String) -> Vec<u8> { + fn from(string: String) -> Vec<u8> { string.into_bytes() } } |
