Stdin how to skip first line


I'm new to Rust and come from JS and TS.

Is there a way to ignore the first line that comes with stdin?

My program will get a file piped in, and the first line us no use to me.

Call read_line once.

But that my code would look like this

let mut dont_need_it = String::new();
let _ = std::io::stdin().read_line(&mut dont_need_it);

let mut stuff_i_need = String::new();
let _ = std::io::stdin().read_line(&mut stuff_i_need);


Yes. Because stdin doesn't implement Iter trait.

Also you can write:

std::io::stdin().read_line(&mut String::new());
1 Like


This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.