pub fn input_fmt<B: BufRead, W: Write>(
src: &mut B,
dst: &mut W,
fmt: Arguments<'_>,
) -> Result<String>Expand description
Writes and flushes a formatted string as prompt text to the dst (Write)
then reads the next line from the src (io::BufRead),
returning it as a io::Result<String>.
§Errors
This function will return any I/O error reported while formatting, flushing or reading.
Also returns an io::ErrorKind::UnexpectedEof error if the stream reaches EOF.
§Example
use std::io::Cursor;
use input_macro::input_fmt;
let mut source = Cursor::new("Joe Bloggs\n");
let mut output = Vec::new();
let name = input_fmt(&mut source, &mut output, format_args!("What's your {}? ", "name"));
assert_eq!(String::from_utf8(output).unwrap(), "What's your name? ");
assert_eq!(name.unwrap(), "Joe Bloggs");