mirror of
https://github.com/rust-lang/rust.git
synced 2024-12-14 09:36:06 +00:00
2b991bc260
`Result::expect()` was added in Rust 1.4. Using it tidies up the code, and also helps by printing error details, eg, printing syntax error details if a regex fails to compile. It adds a colon followed by the `Debug` output from any error, making the periods in messages unnecessary.
17 lines
550 B
Rust
17 lines
550 B
Rust
// rustfmt-chains_overflow_last: false
|
|
|
|
fn main() {
|
|
reader.lines()
|
|
.map(|line| line.expect("Failed getting line"))
|
|
.take_while(|line| line_regex.is_match(&line))
|
|
.filter_map(|line| {
|
|
regex.captures_iter(&line)
|
|
.next()
|
|
.map(|capture| {
|
|
(capture.at(1).expect("Couldn\'t unwrap capture").to_owned(),
|
|
capture.at(2).expect("Couldn\'t unwrap capture").to_owned())
|
|
})
|
|
})
|
|
.collect();
|
|
}
|