read_line_expect

Function read_line_expect 

Source
pub fn read_line_expect<B: BufRead>(src: &mut B) -> Result<String>
Expand description

Reads the next line from src (io::BufRead), mapping EOF to io::ErrorKind::UnexpectedEof and returning a io::Result<String>.

§Errors

This function will return any I/O error reported while reading. Also returns an io::ErrorKind::UnexpectedEof error if src reaches EOF (returns Ok(0)).

§Example

use std::io::Cursor;
use input_macro::read_line_expected;

let mut source = Cursor::new("Insert Text Here\n");
let text = read_line_expected(&mut source);
assert_eq!(text.unwrap(), "Insert Text Here");