File tree 8 files changed +11
-16
lines changed
8 files changed +11
-16
lines changed Original file line number Diff line number Diff line change 1
1
#![ feature( test) ]
2
- #![ feature( core) ]
3
2
4
3
extern crate test;
5
4
@@ -44,7 +43,7 @@ fn recursive_fibonacci(b: &mut Bencher) {
44
43
// exact code to benchmark must be passed as a closure to the iter
45
44
// method of Bencher
46
45
b. iter ( || {
47
- range ( 0 , BENCH_SIZE ) . map ( fibonacci) . collect :: < Vec < u32 > > ( )
46
+ ( 0 .. BENCH_SIZE ) . map ( fibonacci) . collect :: < Vec < u32 > > ( )
48
47
} )
49
48
}
50
49
Original file line number Diff line number Diff line change @@ -29,15 +29,15 @@ fn main() {
29
29
// Iterator that generates: 0, 1 and 2
30
30
let mut sequence = 0 ..3 ;
31
31
32
- println ! ( "Four consecutive `next` calls on range(0, 3) " ) ;
32
+ println ! ( "Four consecutive `next` calls on 0..3 " ) ;
33
33
println ! ( "> {:?}" , sequence. next( ) ) ;
34
34
println ! ( "> {:?}" , sequence. next( ) ) ;
35
35
println ! ( "> {:?}" , sequence. next( ) ) ;
36
36
println ! ( "> {:?}" , sequence. next( ) ) ;
37
37
38
38
// The for construct will iterate an 'Iterator' until it returns 'None'.
39
39
// Every 'Some' value is unwrapped and bound to a variable.
40
- println ! ( "Iterate over range(0, 3) using for" ) ;
40
+ println ! ( "Iterate over 0..3 using for" ) ;
41
41
for i in 0 ..3 {
42
42
println ! ( "> {}" , i) ;
43
43
}
Original file line number Diff line number Diff line change 1
- #![ feature( core) ]
2
-
3
1
use std:: iter;
4
2
use std:: ops:: { Add , Mul , Sub } ;
5
3
@@ -48,7 +46,7 @@ mod test {
48
46
( $func: ident, $x: expr, $y: expr, $z: expr) => {
49
47
#[ test]
50
48
fn $func( ) {
51
- for size in range ( 0u32 , 10 ) {
49
+ for size in 0u32 .. 10 {
52
50
let mut x: Vec <_> = iter:: repeat( size) . take( $x) . collect( ) ;
53
51
let y: Vec <_> = iter:: repeat( size) . take( $y) . collect( ) ;
54
52
let z: Vec <_> = iter:: repeat( size) . take( $z) . collect( ) ;
Original file line number Diff line number Diff line change 1
1
#![ feature( box_syntax) ]
2
- #![ feature( core) ]
3
2
4
3
fn create_box ( ) {
5
4
// Allocate an integer in the heap
@@ -21,7 +20,7 @@ fn main() {
21
20
}
22
21
23
22
// Create lots of boxes
24
- for _ in range ( 0u32 , 1_000 ) {
23
+ for _ in 0u32 .. 1_000 {
25
24
create_box ( ) ;
26
25
}
27
26
Original file line number Diff line number Diff line change @@ -33,7 +33,7 @@ fn simd_add_assign(xs: &mut Vec<f32>, ys: &Vec<f32>) {
33
33
let p_y: * const f32 = ys. as_ptr ( ) ;
34
34
35
35
// sum excess elements that don't fit in the simd vector
36
- for i in range ( 4 * chunks, size ) {
36
+ for i in ( 4 * chunks) ..size {
37
37
// dereferencing a raw pointer requires an unsafe block
38
38
unsafe {
39
39
// offset by i elements
@@ -46,7 +46,7 @@ fn simd_add_assign(xs: &mut Vec<f32>, ys: &Vec<f32>) {
46
46
let simd_p_y = p_y as * const f32x4 ;
47
47
48
48
// sum "simd vector"
49
- for i in range ( 0 , chunks) {
49
+ for i in 0 .. chunks {
50
50
unsafe {
51
51
* simd_p_x. offset ( i) += * simd_p_y. offset ( i) ;
52
52
}
Original file line number Diff line number Diff line change 1
- #![ feature( core) ]
2
1
#![ feature( std_misc) ]
3
2
4
3
use std:: thread:: Thread ;
@@ -7,7 +6,7 @@ static NTHREADS: i32 = 10;
7
6
8
7
// This is the `main` thread
9
8
fn main ( ) {
10
- for i in range ( 0 , NTHREADS ) {
9
+ for i in 0 .. NTHREADS {
11
10
// Spin up another thread
12
11
let _ = Thread :: scoped ( move || {
13
12
println ! ( "this is thread number {}" , i)
Original file line number Diff line number Diff line change 1
1
fn main ( ) {
2
2
// Iterators can be collected into vectors
3
- let collected_iterator: Vec < i32 > = range ( 0 , 10 ) . collect ( ) ;
4
- println ! ( "Collected range(0, 10) into: {:?}" , collected_iterator) ;
3
+ let collected_iterator: Vec < i32 > = ( 0 .. 10 ) . collect ( ) ;
4
+ println ! ( "Collected (0.. 10) into: {:?}" , collected_iterator) ;
5
5
6
6
// The `vec!` macro can be used to initialize a vector
7
7
let mut xs = vec ! [ 1i32 , 2 , 3 ] ;
Original file line number Diff line number Diff line change @@ -37,7 +37,7 @@ fn main() {
37
37
nexamples += count;
38
38
}
39
39
40
- let mut entries = range ( 0 , nexamples) . map ( |_| {
40
+ let mut entries = ( 0 .. nexamples) . map ( |_| {
41
41
rx. recv ( ) . unwrap ( )
42
42
} ) . collect :: < Vec < ( Vec < uint > , String ) > > ( ) ;
43
43
You can’t perform that action at this time.
0 commit comments