File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -46,6 +46,19 @@ fn main() {
4646}
4747```
4848
49+ Just remember that even though you can compile the code when a>b, the loop gets
50+ never executed.
51+ ``` rust,editable
52+ for i in 10..1{
53+ println!("fizzbuzz");
54+ }
55+ ```
56+ If you want to count down, you need to use .rev() instead
57+ ``` rust,editable
58+ for i in (1..10).rev(){
59+ println!("fizzbuzz");
60+ }
61+ ```
4962## for and iterators
5063
5164The ` for in ` construct is able to interact with an ` Iterator ` in several ways.
Original file line number Diff line number Diff line change @@ -16,8 +16,8 @@ fn main() {
1616 // copy `an_integer` into `copied_integer`
1717 let copied_integer = an_integer;
1818
19- println!("An integer: {:? }", copied_integer);
20- println!("A boolean: {:? }", a_boolean);
19+ println!("An integer: {}", copied_integer);
20+ println!("A boolean: {}", a_boolean);
2121 println!("Meet the unit value: {:?}", unit);
2222
2323 // The compiler warns about unused variable bindings; these warnings can
You can’t perform that action at this time.
0 commit comments