pub trait Read: IntoIterator + Read {
// Required methods
fn read_all(&mut self) -> String;
fn read_line(&mut self) -> String;
// Provided method
fn read_line_any<T: FromStr>(&mut self) -> T
where Self: Sized { ... }
}
Expand description
A trait for objects which can read data.
Can be turned into an iterator to read all available lines as strings.
Required Methods§
sourcefn read_all(&mut self) -> String
fn read_all(&mut self) -> String
Read and return all available data from self.
Panics if there is an error reading.
sourcefn read_line(&mut self) -> String
fn read_line(&mut self) -> String
Read and return a single line of data from self.
Panics if there is an error reading. Note that for finite data sources (e.g., files) this function will panic when the reader is exhausted. To get all lines (if the number of lines is not known in advance), convert the reader into an iterator instead.
Does not return the terminal newline character.
Provided Methods§
sourcefn read_line_any<T: FromStr>(&mut self) -> Twhere
Self: Sized,
fn read_line_any<T: FromStr>(&mut self) -> Twhere
Self: Sized,
Read, parse, and return a single line of data from self.
Panics if there is an error reading or parsing data.