]> git.lizzy.rs Git - rust.git/commitdiff
iterator: UnfoldrIterator::new should have function argument last
authorblake2-ppc <blake2-ppc>
Fri, 28 Jun 2013 11:52:37 +0000 (13:52 +0200)
committerDaniel Micay <danielmicay@gmail.com>
Sat, 29 Jun 2013 05:03:37 +0000 (01:03 -0400)
To match Rust conventions and enable use of `do` etc, make sure the
closure is the last argument to the `new` method.

src/libstd/iterator.rs
src/test/run-pass/unfoldr-cross-crate.rs

index 78940143f4e3df990cdf6c7bee519ecd7812e073..765bf3b36f2850b833995f84b31d5446cac9b026 100644 (file)
@@ -983,7 +983,7 @@ impl<'self, A, St> UnfoldrIterator<'self, A, St> {
     /// Creates a new iterator with the specified closure as the "iterator
     /// function" and an initial state to eventually pass to the iterator
     #[inline]
-    pub fn new<'a>(f: &'a fn(&mut St) -> Option<A>, initial_state: St)
+    pub fn new<'a>(initial_state: St, f: &'a fn(&mut St) -> Option<A>)
         -> UnfoldrIterator<'a, A, St> {
         UnfoldrIterator {
             f: f,
@@ -1174,7 +1174,7 @@ fn count(st: &mut uint) -> Option<uint> {
             }
         }
 
-        let mut it = UnfoldrIterator::new(count, 0);
+        let mut it = UnfoldrIterator::new(0, count);
         let mut i = 0;
         for it.advance |counted| {
             assert_eq!(counted, i);
index 4e98543ae826ea7e7e8ea2fc0ab2da978be6e5ca..7fcae90a8d1177d28fb8eb40f906fc5602cbb9df 100644 (file)
@@ -24,7 +24,7 @@ fn count(st: &mut uint) -> Option<uint> {
         }
     }
 
-    let mut it = UnfoldrIterator::new(count, 0);
+    let mut it = UnfoldrIterator::new(0, count);
     let mut i = 0;
     for it.advance |counted| {
         assert_eq!(counted, i);