Stdin how to skip first line

Hello,

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

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

Scenario
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);

Correct.

Yes. Because stdin doesn't implement Iter trait.

Also you can write:

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

thx