diff options
| author | Nick Cameron <ncameron@mozilla.com> | 2014-08-04 14:19:02 +0200 |
|---|---|---|
| committer | Nick Cameron <ncameron@mozilla.com> | 2014-08-26 12:37:45 +1200 |
| commit | 37a94b80f207e86017e54056ced2dc9674907ae3 (patch) | |
| tree | 05fca5f77317c944b5d8da3198e8a0619fb60225 /src/libcore | |
| parent | 34d607f9c9e3c103fc7f98b4c6fa18ff71905bb6 (diff) | |
Use temp vars for implicit coercion to ^[T]
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/option.rs | 10 | ||||
| -rw-r--r-- | src/libcore/str.rs | 19 |
2 files changed, 20 insertions, 9 deletions
diff --git a/src/libcore/option.rs b/src/libcore/option.rs index bf8a92a4f95..47df8ae68cd 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -221,8 +221,14 @@ impl<T> Option<T> { #[inline] pub fn as_mut_slice<'r>(&'r mut self) -> &'r mut [T] { match *self { - Some(ref mut x) => slice::mut_ref_slice(x), - None => &mut [] + Some(ref mut x) => { + let result: &mut [T] = slice::mut_ref_slice(x); + result + } + None => { + let result: &mut [T] = &mut []; + result + } } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 66564b1bf07..5cbeda94d0f 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -918,8 +918,8 @@ pub fn utf16_items<'a>(v: &'a [u16]) -> Utf16Items<'a> { /// /// // "ab\0d" /// v[2] = 0; -/// assert_eq!(str::truncate_utf16_at_nul(v), -/// &['a' as u16, 'b' as u16]); +/// let b: &[_] = &['a' as u16, 'b' as u16]; +/// assert_eq!(str::truncate_utf16_at_nul(v), b); /// ``` pub fn truncate_utf16_at_nul<'a>(v: &'a [u16]) -> &'a [u16] { match v.iter().position(|c| *c == 0) { @@ -1439,7 +1439,8 @@ pub trait StrSlice<'a> { /// /// ```rust /// assert_eq!("11foo1bar11".trim_chars('1'), "foo1bar") - /// assert_eq!("12foo1bar12".trim_chars(&['1', '2']), "foo1bar") + /// let x: &[_] = &['1', '2']; + /// assert_eq!("12foo1bar12".trim_chars(x), "foo1bar") /// assert_eq!("123foo1bar123".trim_chars(|c: char| c.is_digit()), "foo1bar") /// ``` fn trim_chars<C: CharEq>(&self, to_trim: C) -> &'a str; @@ -1454,7 +1455,8 @@ pub trait StrSlice<'a> { /// /// ```rust /// assert_eq!("11foo1bar11".trim_left_chars('1'), "foo1bar11") - /// assert_eq!("12foo1bar12".trim_left_chars(&['1', '2']), "foo1bar12") + /// let x: &[_] = &['1', '2']; + /// assert_eq!("12foo1bar12".trim_left_chars(x), "foo1bar12") /// assert_eq!("123foo1bar123".trim_left_chars(|c: char| c.is_digit()), "foo1bar123") /// ``` fn trim_left_chars<C: CharEq>(&self, to_trim: C) -> &'a str; @@ -1469,7 +1471,8 @@ pub trait StrSlice<'a> { /// /// ```rust /// assert_eq!("11foo1bar11".trim_right_chars('1'), "11foo1bar") - /// assert_eq!("12foo1bar12".trim_right_chars(&['1', '2']), "12foo1bar") + /// let x: &[_] = &['1', '2']; + /// assert_eq!("12foo1bar12".trim_right_chars(x), "12foo1bar") /// assert_eq!("123foo1bar123".trim_right_chars(|c: char| c.is_digit()), "123foo1bar") /// ``` fn trim_right_chars<C: CharEq>(&self, to_trim: C) -> &'a str; @@ -1620,7 +1623,8 @@ pub trait StrSlice<'a> { /// assert_eq!(s.find(|c: char| c.is_whitespace()), Some(5)); /// /// // neither are found - /// assert_eq!(s.find(&['1', '2']), None); + /// let x: &[_] = &['1', '2']; + /// assert_eq!(s.find(x), None); /// ``` fn find<C: CharEq>(&self, search: C) -> Option<uint>; @@ -1644,7 +1648,8 @@ pub trait StrSlice<'a> { /// assert_eq!(s.rfind(|c: char| c.is_whitespace()), Some(12)); /// /// // searches for an occurrence of either `1` or `2`, but neither are found - /// assert_eq!(s.rfind(&['1', '2']), None); + /// let x: &[_] = &['1', '2']; + /// assert_eq!(s.rfind(x), None); /// ``` fn rfind<C: CharEq>(&self, search: C) -> Option<uint>; |
