From bf6c007760169e9c382d3700fd1cdd20037e4343 Mon Sep 17 00:00:00 2001 From: Huon Wilson Date: Fri, 5 Dec 2014 15:56:25 -0800 Subject: Change `&` pat to only work with &T, and `&mut` with &mut T. This implements RFC 179 by making the pattern `&` require matching against a variable of type `&T`, and introducing the pattern `&mut ` which only works with variables of type `&mut T`. The pattern `&mut x` currently parses as `&(mut x)` i.e. a pattern match through a `&T` or a `&mut T` that binds the variable `x` to have type `T` and to be mutable. This should be rewritten as follows, for example, for &mut x in slice.iter() { becomes for &x in slice.iter() { let mut x = x; Due to this, this is a [breaking-change] Closes #20496. --- src/libcore/str/mod.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/libcore/str') diff --git a/src/libcore/str/mod.rs b/src/libcore/str/mod.rs index d069744f8da..b497e9733bc 100644 --- a/src/libcore/str/mod.rs +++ b/src/libcore/str/mod.rs @@ -230,7 +230,7 @@ impl CharEq for F where F: FnMut(char) -> bool { impl<'a> CharEq for &'a [char] { #[inline] fn matches(&mut self, c: char) -> bool { - self.iter().any(|&mut m| m.matches(c)) + self.iter().any(|&m| { let mut m = m; m.matches(c) }) } #[inline] -- cgit 1.4.1-3-g733a5