debian/rust-vendor/bstr/examples/lines.rs
raw| 1 | use std::error::Error; |
| 2 | use std::io::{self, Write}; |
| 3 | |
| 4 | use bstr::{io::BufReadExt, ByteSlice}; |
| 5 | |
| 6 | fn main() -> Result<(), Box<dyn Error>> { |
| 7 | let stdin = io::stdin(); |
| 8 | let mut stdout = io::BufWriter::new(io::stdout()); |
| 9 | |
| 10 | stdin.lock().for_byte_line_with_terminator(|line| { |
| 11 | if line.contains_str("Dimension") { |
| 12 | stdout.write_all(line)?; |
| 13 | } |
| 14 | Ok(true) |
| 15 | })?; |
| 16 | Ok(()) |
| 17 | } |