.nth(0)
RS-W1053.nth(0)
when .next()
would suffice 14 let Some(contents) = std::fs::read_to_string(file).ok() else {
15 return None;
16 };
17 let args: Vec<String> = snailquote::escape(contents.lines().nth(0).unwrap()) 18 .split_whitespace()
19 .map(|x| x.to_string())
20 .collect();
next()
is equivalent to and more readable than nth(0)
.
let char_list = "string".chars();
if let Some(s) = char_list.nth(0) {
// ...
}
let char_list = "string".chars();
if let Some(s) = char_list.next() {
// ...
}