Rust Iterators

let us look at Rust iterators examples.

fn main() {

   let arr = [11,12,13,14];

   let iterator = arr.iter();
   for data in iterator{
      print!("{}\t",data);
   }

   print!("\n");
}

The code above is compiled using the below command.

apples-MacBook-Air:iterators bhagvan.kommadi$ rustc iterator.rs

The output will be as below:

apples-MacBook-Air:iterators bhagvan.kommadi$ ./iterator
11	12	13	14

Leave a comment