Selaa lähdekoodia

looping

`for` loops only support looping over iterable things, not explicit
looping.  maybe there is support for something like `(0..10).step(2)` or
similar.  `while` exists as well.  for infinite loops `loop` should be
used to help the compiler along.
Lucas Stadler 10 vuotta sitten
vanhempi
commit
be4e3a9945
1 muutettua tiedostoa jossa 5 lisäystä ja 0 poistoa
  1. 5 0
      rust/book/src/main.rs

+ 5 - 0
rust/book/src/main.rs

@ -87,4 +87,9 @@ fn main() {
87 87
    print_num_type(i);
88 88
    print_num_type(f);
89 89
    print_num_type(n);
90
91
    // loops
92
    for x in 0..10 {
93
        println!("{}", x);
94
    }
90 95
}