It should be simple:
for (linenumber, line) in lines.enumerate() { println!("{}: {}", linenumber, line); }
You can also do
#[macro_use] extern crate itertools; fn main() { for (linenumber, line) in izip!(0.., lines) { println!("{}, {}", linenumber, line); } }
for more flexibility. The advantage of this is that you can change things such as the start and numbering steps, as well as the number of items zipped.
source share