[code] iterators all the way
This commit is contained in:
parent
ae83358d14
commit
1daa5d5304
10
src/main.rs
10
src/main.rs
@ -45,12 +45,10 @@ where
|
||||
|
||||
fn trim_end(line: &[u8]) -> usize {
|
||||
let mut end = line.len();
|
||||
for ch in line.iter().rev() {
|
||||
if *ch != b'\r' && *ch != b'\n' && *ch != b'\t' {
|
||||
break;
|
||||
}
|
||||
end -= 1;
|
||||
}
|
||||
line.iter()
|
||||
.rev()
|
||||
.take_while(|ch| ch.is_ascii_whitespace())
|
||||
.for_each(|_| end -= 1);
|
||||
end
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user