pub struct ScanLines<R: Read> { /* private fields */ }
Expand description
used to generate Scanner structs for each line
Implementations§
source§impl<'a, R: Read> ScanLines<R>
impl<'a, R: Read> ScanLines<R>
sourcepub fn new(f: R) -> ScanLines<R>
pub fn new(f: R) -> ScanLines<R>
create a Scanner ‘iterator’ over all lines from a readable.
This cannot be a proper Iterator
because the lifetime constraint
on Scanner
cannot be satisfied. You need to use the explicit form:
ⓘ
let mut iter = ScanLines::new(File::open("lines.txt")?);
while let Some(s) = iter.next() {
let mut s = s?;
// first token of each line
println!("{:?}",s.get());
}