]> git.lizzy.rs Git - rust.git/blobdiff - src/test/run-pass/issue-14919.rs
cleanup: s/impl Copy/#[derive(Copy)]/g
[rust.git] / src / test / run-pass / issue-14919.rs
index db29eb314bd70455492702b273b18600197f107a..4d05b98147bd6237ec9ba8b5c065a8d0c02f5cb6 100644 (file)
@@ -8,13 +8,16 @@
 // option. This file may not be copied, modified, or distributed
 // except according to those terms.
 
+#![allow(unknown_features)]
+#![feature(box_syntax)]
+
 trait Matcher {
     fn next_match(&mut self) -> Option<(uint, uint)>;
 }
 
 struct CharPredMatcher<'a, 'b> {
     str: &'a str,
-    pred: |char|:'b -> bool
+    pred: Box<FnMut(char) -> bool + 'b>,
 }
 
 impl<'a, 'b> Matcher for CharPredMatcher<'a, 'b> {
@@ -27,11 +30,11 @@ trait IntoMatcher<'a, T> {
     fn into_matcher(self, &'a str) -> T;
 }
 
-impl<'a, 'b> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for |char|:'b -> bool {
+impl<'a, 'b, F> IntoMatcher<'a, CharPredMatcher<'a, 'b>> for F where F: FnMut(char) -> bool + 'b {
     fn into_matcher(self, s: &'a str) -> CharPredMatcher<'a, 'b> {
         CharPredMatcher {
             str: s,
-            pred: self
+            pred: box self,
         }
     }
 }
@@ -40,7 +43,9 @@ struct MatchIndices<M> {
     matcher: M
 }
 
-impl<M: Matcher> Iterator<(uint, uint)> for MatchIndices<M> {
+impl<M: Matcher> Iterator for MatchIndices<M> {
+    type Item = (uint, uint);
+
     fn next(&mut self) -> Option<(uint, uint)> {
         self.matcher.next_match()
     }
@@ -53,6 +58,6 @@ fn match_indices<'a, M, T: IntoMatcher<'a, M>>(s: &'a str, from: T) -> MatchIndi
 
 fn main() {
     let s = "abcbdef";
-    match_indices(s, |c: char| c == 'b')
+    match_indices(s, |&mut: c: char| c == 'b')
         .collect::<Vec<(uint, uint)>>();
 }