#![feature(plugin, core, test)]
#![plugin(speculate)]

extern crate test;

speculate! {
    bench "noop" |b| {
        b.iter(|| ());
    }

    describe "xor" {
        context "0 to 1000" {
            before {
                let limit = 1000u32;
            }

            bench "using `fold`" |b| {
                b.iter(|| (0..limit).fold(0, |a, b| a ^ b));
            }

            bench "using `for`" |b| {
                b.iter(|| {
                    let mut ret = 0;
                    for i in 0..limit {
                        ret ^= i;
                    }
                    ret
                });
            }

            after {
                assert_eq!(limit, 1000);
            }
        }
    }
}

#![feature(plugin, core, test)]
#![plugin(speculate)]

extern crate test;

speculate! {
    bench "noop" |b| {
        b.iter(|| ());
    }

    describe "xor" {
        context "0 to 1000" {
            before {
                let limit = 1000u32;
            }

            bench "using `fold`" |b| {
                b.iter(|| range(0, limit).fold(0, |a, b| a ^ b));
            }

            bench "using `for`" |b| {
                b.iter(|| {
                    let mut ret = 0;
                    for i in range(0, limit) {
                        ret ^= i;
                    }
                    ret
                });
            }

            after {
                assert_eq!(limit, 1000);
            }
        }
    }
}

--- 
+++ 
@@ -15,13 +15,13 @@
             }
 
             bench "using `fold`" |b| {
-                b.iter(|| (0..limit).fold(0, |a, b| a ^ b));
+                b.iter(|| range(0, limit).fold(0, |a, b| a ^ b));
             }
 
             bench "using `for`" |b| {
                 b.iter(|| {
                     let mut ret = 0;
-                    for i in 0..limit {
+                    for i in range(0, limit) {
                         ret ^= i;
                     }
                     ret
Fix for `rustc 1.0.0-dev (ecf8c64e1 2015-03-21) (built 2015-03-21)`.
