debian/missing-sources/bstr/examples/uppercase.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 | let mut upper = vec![]; |
| 11 | stdin.lock().for_byte_line_with_terminator(|line| { |
| 12 | upper.clear(); |
| 13 | line.to_uppercase_into(&mut upper); |
| 14 | stdout.write_all(&upper)?; |
| 15 | Ok(true) |
| 16 | })?; |
| 17 | Ok(()) |
| 18 | } |