diff --git a/src/libcollections/str.rs b/src/libcollections/str.rs index 9ae009d8f6a5..aaa7da312f29 100644 --- a/src/libcollections/str.rs +++ b/src/libcollections/str.rs @@ -1263,13 +1263,13 @@ mod tests { #[test] fn test_slice_shift_char() { let data = "ประเทศไทย中"; - assert_eq!(data.slice_shift_char(), (Some('ป'), "ระเทศไทย中")); + assert_eq!(data.slice_shift_char(), Some(('ป', "ระเทศไทย中"))); } #[test] fn test_slice_shift_char_2() { let empty = ""; - assert_eq!(empty.slice_shift_char(), (None, "")); + assert_eq!(empty.slice_shift_char(), None); } #[test] diff --git a/src/libcore/num/mod.rs b/src/libcore/num/mod.rs index 800b0c1a9059..01c9277a20b7 100644 --- a/src/libcore/num/mod.rs +++ b/src/libcore/num/mod.rs @@ -1457,10 +1457,10 @@ macro_rules! from_str_radix_float_impl { } let (is_positive, src) = match src.slice_shift_char() { - (None, _) => return None, - (Some('-'), "") => return None, - (Some('-'), src) => (false, src), - (Some(_), _) => (true, src), + None => return None, + Some(('-', "")) => return None, + Some(('-', src)) => (false, src), + Some((_, _)) => (true, src), }; // The significand to accumulate @@ -1563,10 +1563,10 @@ macro_rules! from_str_radix_float_impl { // Parse the exponent as decimal integer let src = src[offset..]; let (is_positive, exp) = match src.slice_shift_char() { - (Some('-'), src) => (false, from_str::(src)), - (Some('+'), src) => (true, from_str::(src)), - (Some(_), _) => (true, from_str::(src)), - (None, _) => return None, + Some(('-', src)) => (false, from_str::(src)), + Some(('+', src)) => (true, from_str::(src)), + Some((_, _)) => (true, from_str::(src)), + None => return None, }; match (is_positive, exp) { @@ -1606,7 +1606,7 @@ macro_rules! from_str_radix_int_impl { let is_signed_ty = (0 as $T) > Int::min_value(); match src.slice_shift_char() { - (Some('-'), src) if is_signed_ty => { + Some(('-', src)) if is_signed_ty => { // The number is negative let mut result = 0; for c in src.chars() { @@ -1625,7 +1625,7 @@ macro_rules! from_str_radix_int_impl { } Some(result) }, - (Some(_), _) => { + Some((_, _)) => { // The number is signed let mut result = 0; for c in src.chars() { @@ -1644,7 +1644,7 @@ macro_rules! from_str_radix_int_impl { } Some(result) }, - (None, _) => None, + None => None, } } } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index bc30429c05c9..24f26b15f27a 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -1811,21 +1811,21 @@ pub trait StrPrelude for Sized? { /// it. This does not allocate a new string; instead, it returns a /// slice that point one character beyond the character that was /// shifted. If the string does not contain any characters, - /// a tuple of None and an empty string is returned instead. + /// None is returned instead. /// /// # Example /// /// ```rust /// let s = "Löwe 老虎 Léopard"; - /// let (c, s1) = s.slice_shift_char(); - /// assert_eq!(c, Some('L')); + /// let (c, s1) = s.slice_shift_char().unwrap(); + /// assert_eq!(c, 'L'); /// assert_eq!(s1, "öwe 老虎 Léopard"); /// - /// let (c, s2) = s1.slice_shift_char(); - /// assert_eq!(c, Some('ö')); + /// let (c, s2) = s1.slice_shift_char().unwrap(); + /// assert_eq!(c, 'ö'); /// assert_eq!(s2, "we 老虎 Léopard"); /// ``` - fn slice_shift_char<'a>(&'a self) -> (Option, &'a str); + fn slice_shift_char<'a>(&'a self) -> Option<(char, &'a str)>; /// Returns the byte offset of an inner slice relative to an enclosing outer slice. /// @@ -2197,13 +2197,13 @@ impl StrPrelude for str { } #[inline] - fn slice_shift_char(&self) -> (Option, &str) { + fn slice_shift_char(&self) -> Option<(char, &str)> { if self.is_empty() { - return (None, self); + None } else { let CharRange {ch, next} = self.char_range_at(0u); let next_s = unsafe { raw::slice_bytes(self, next, self.len()) }; - return (Some(ch), next_s); + Some((ch, next_s)) } } diff --git a/src/libsyntax/ext/asm.rs b/src/libsyntax/ext/asm.rs index 8027d9bfd8a8..d04144ef26e5 100644 --- a/src/libsyntax/ext/asm.rs +++ b/src/libsyntax/ext/asm.rs @@ -97,8 +97,8 @@ pub fn expand_asm<'cx>(cx: &'cx mut ExtCtxt, sp: Span, tts: &[ast::TokenTree]) // cannot be shared with any other operand (usually when // a register is clobbered early.) let output = match constraint.get().slice_shift_char() { - (Some('='), _) => None, - (Some('+'), operand) => { + Some(('=', _)) => None, + Some(('+', operand)) => { Some(token::intern_and_get_ident(format!( "={}", operand).as_slice())) diff --git a/src/libsyntax/print/pprust.rs b/src/libsyntax/print/pprust.rs index 390a5cc68d30..81f3d977e13f 100644 --- a/src/libsyntax/print/pprust.rs +++ b/src/libsyntax/print/pprust.rs @@ -1855,7 +1855,7 @@ impl<'a> State<'a> { try!(self.commasep(Inconsistent, a.outputs.as_slice(), |s, &(ref co, ref o, is_rw)| { match co.get().slice_shift_char() { - (Some('='), operand) if is_rw => { + Some(('=', operand)) if is_rw => { try!(s.print_string(format!("+{}", operand).as_slice(), ast::CookedStr)) }