From: Ralf Jung Date: Thu, 9 Jul 2015 20:56:33 +0000 (+0200) Subject: be more explicit about dereferencing X-Git-Url: https://git.ralfj.de/rust-101.git/commitdiff_plain/342e299d8a8fd79f07960312b73e241c6cc0400e?ds=sidebyside;hp=942f0abd4b0931acad2d3def58cb7273ace15e2a be more explicit about dereferencing --- diff --git a/src/part10.rs b/src/part10.rs index c8a0129..452e993 100644 --- a/src/part10.rs +++ b/src/part10.rs @@ -115,7 +115,7 @@ fn inc_print_even(v: &Vec, offset: i32, threshold: i32) { //@ //@ Since all these closures compile down to the pattern described above, there is actually no heap allocation going on here. This makes //@ closures very efficient, and it makes optimization fairly trivial: The resulting code will look like you hand-rolled the loop in C. - for i in v.iter().map(|n| n + offset).filter(|n| *n > threshold) { + for i in v.iter().map(|n| *n + offset).filter(|n| *n > threshold) { println!("{}", i); } } diff --git a/workspace/src/part10.rs b/workspace/src/part10.rs index f7d9028..7af1617 100644 --- a/workspace/src/part10.rs +++ b/workspace/src/part10.rs @@ -76,7 +76,7 @@ pub fn print_and_count(b: &BigInt) { // Let's say we want to write a function that increments every entry of a `Vec` by some number, then looks for numbers larger than some threshold, and prints them. fn inc_print_even(v: &Vec, offset: i32, threshold: i32) { - for i in v.iter().map(|n| n + offset).filter(|n| *n > threshold) { + for i in v.iter().map(|n| *n + offset).filter(|n| *n > threshold) { println!("{}", i); } }