diff options
Diffstat (limited to 'vendor/bstr/examples/uppercase-std.rs')
-rw-r--r-- | vendor/bstr/examples/uppercase-std.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/vendor/bstr/examples/uppercase-std.rs b/vendor/bstr/examples/uppercase-std.rs new file mode 100644 index 000000000..672bd7171 --- /dev/null +++ b/vendor/bstr/examples/uppercase-std.rs @@ -0,0 +1,15 @@ +use std::error::Error; +use std::io::{self, BufRead, Write}; + +fn main() -> Result<(), Box<dyn Error>> { + let stdin = io::stdin(); + let mut stdin = stdin.lock(); + let mut stdout = io::BufWriter::new(io::stdout()); + + let mut line = String::new(); + while stdin.read_line(&mut line)? > 0 { + stdout.write_all(line.to_uppercase().as_bytes())?; + line.clear(); + } + Ok(()) +} |