-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Write unchanged, excluded files to stdout when read via stdin
- Loading branch information
1 parent
0ac124a
commit 3296387
Showing
4 changed files
with
32 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,17 @@ | ||
use std::io; | ||
use std::io::Read; | ||
use std::io::{Read, Write}; | ||
|
||
/// Read a string from `stdin`. | ||
pub(crate) fn read_from_stdin() -> Result<String, io::Error> { | ||
let mut buffer = String::new(); | ||
io::stdin().lock().read_to_string(&mut buffer)?; | ||
Ok(buffer) | ||
} | ||
|
||
/// Read bytes from `stdin` and write them to `stdout`. | ||
pub(crate) fn parrot_stdin() -> Result<(), io::Error> { | ||
let mut buffer = String::new(); | ||
io::stdin().lock().read_to_string(&mut buffer)?; | ||
io::stdout().write_all(&buffer.as_bytes())?; | ||
Ok(()) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters