@@ -31,6 +31,7 @@ use mem;
31
31
use num:: Int ;
32
32
use option:: Option ;
33
33
use option:: Option :: { None , Some } ;
34
+ use ops:: FnMut ;
34
35
use ptr:: RawPtr ;
35
36
use raw:: { Repr , Slice } ;
36
37
use slice:: { mod, SlicePrelude } ;
@@ -136,15 +137,7 @@ impl CharEq for char {
136
137
fn only_ascii ( & self ) -> bool { ( * self as uint ) < 128 }
137
138
}
138
139
139
- impl < ' a > CharEq for |char|: ' a -> bool {
140
- #[ inline]
141
- fn matches ( & mut self , c : char ) -> bool { ( * self ) ( c) }
142
-
143
- #[ inline]
144
- fn only_ascii ( & self ) -> bool { false }
145
- }
146
-
147
- impl CharEq for extern "Rust" fn ( char ) -> bool {
140
+ impl < F > CharEq for F where F : FnMut ( char ) -> bool {
148
141
#[ inline]
149
142
fn matches ( & mut self , c : char ) -> bool { ( * self ) ( c) }
150
143
@@ -2142,11 +2135,11 @@ impl StrPrelude for str {
2142
2135
2143
2136
#[ inline]
2144
2137
fn trim_chars < C : CharEq > ( & self , mut to_trim : C ) -> & str {
2145
- let cur = match self . find ( |c : char | !to_trim. matches ( c) ) {
2138
+ let cur = match self . find ( |& mut : c: char | !to_trim. matches ( c) ) {
2146
2139
None => "" ,
2147
2140
Some ( i) => unsafe { self . slice_unchecked ( i, self . len ( ) ) }
2148
2141
} ;
2149
- match cur. rfind ( |c : char | !to_trim. matches ( c) ) {
2142
+ match cur. rfind ( |& mut : c: char | !to_trim. matches ( c) ) {
2150
2143
None => "" ,
2151
2144
Some ( i) => {
2152
2145
let right = cur. char_range_at ( i) . next ;
@@ -2157,15 +2150,15 @@ impl StrPrelude for str {
2157
2150
2158
2151
#[ inline]
2159
2152
fn trim_left_chars < C : CharEq > ( & self , mut to_trim : C ) -> & str {
2160
- match self . find ( |c : char | !to_trim. matches ( c) ) {
2153
+ match self . find ( |& mut : c: char | !to_trim. matches ( c) ) {
2161
2154
None => "" ,
2162
2155
Some ( first) => unsafe { self . slice_unchecked ( first, self . len ( ) ) }
2163
2156
}
2164
2157
}
2165
2158
2166
2159
#[ inline]
2167
2160
fn trim_right_chars < C : CharEq > ( & self , mut to_trim : C ) -> & str {
2168
- match self . rfind ( |c : char | !to_trim. matches ( c) ) {
2161
+ match self . rfind ( |& mut : c: char | !to_trim. matches ( c) ) {
2169
2162
None => "" ,
2170
2163
Some ( last) => {
2171
2164
let next = self . char_range_at ( last) . next ;
0 commit comments