[][src]Struct str_reader::StringReader

pub struct StringReader<'a> { /* fields omitted */ }

String reader.

Implementations

impl<'a> StringReader<'a>[src]

pub fn new<T: ?Sized>(input: &'a T) -> Self where
    T: AsRef<str>, 
[src]

Create a new reader for a given input.

Arguments

  • input - input string or an object that can be referenced as a string

pub fn current_char(&self) -> Option<char>[src]

Get the current character (if any) without advancing the input.

pub fn read_char(&mut self) -> Result<char, ParseError>[src]

Get the next character or return an error if the input is empty.

pub fn match_char(&mut self, expected: char) -> Result<(), ParseError>[src]

Match a given character to the input and, if successful, advance the input by exactly one character. An error is returned if the input character does not match with the given one or if the input is empty.

Arguments

  • expected - expected character

pub fn skip_char(&mut self)[src]

Skip one character.

pub fn skip_whitespace(&mut self)[src]

Skip all whitespace characters.

pub fn match_str(&mut self, val: &str) -> Result<(), ParseError>[src]

Match a given string to the input and, if successful, advance the input by the length of the given string. An error is returned if the input does not start with the given string.

Arguments

  • val - expected string

pub fn read_until<F>(&mut self, cnd: F) -> &'a str where
    F: FnMut(char) -> bool
[src]

Read until a given condition is true or until the end of the input and return the string.

Arguments

  • cnd - a closure that takes a single character and returns true/false

pub fn read_word(&mut self) -> &'a str[src]

Read one word from the input and return it. A word ends with the first whitespace character or with the end of the input. The method skips all initial whitespace characters (if any).

pub fn parse_word<T>(&mut self) -> Result<T, T::Err> where
    T: FromStr
[src]

Read the next word and parse it. The input won't be advanced if the word cannot be parsed.

pub fn read_i8(&mut self) -> Result<i8, ParseIntError>[src]

Read a decimal integer as i8.

pub fn read_u8(&mut self) -> Result<u8, ParseIntError>[src]

Read a decimal integer as u8.

pub fn read_i16(&mut self) -> Result<i16, ParseIntError>[src]

Read a decimal integer as i16.

pub fn read_u16(&mut self) -> Result<u16, ParseIntError>[src]

Read a decimal integer as u16.

pub fn read_i32(&mut self) -> Result<i32, ParseIntError>[src]

Read a decimal integer as i32.

pub fn read_u32(&mut self) -> Result<u32, ParseIntError>[src]

Read a decimal integer as u32.

pub fn read_i64(&mut self) -> Result<i64, ParseIntError>[src]

Read a decimal integer as i64.

pub fn read_u64(&mut self) -> Result<u64, ParseIntError>[src]

Read a decimal integer as u64.

pub fn read_i128(&mut self) -> Result<i128, ParseIntError>[src]

Read a decimal integer as i128.

pub fn read_u128(&mut self) -> Result<u128, ParseIntError>[src]

Read a decimal integer as u128.

pub fn read_isize(&mut self) -> Result<isize, ParseIntError>[src]

Read a decimal integer as isize.

pub fn read_usize(&mut self) -> Result<usize, ParseIntError>[src]

Read a decimal integer as usize.

pub fn read_f32(&mut self) -> Result<f32, ParseFloatError>[src]

Read a floating point number as f32.

pub fn read_f64(&mut self) -> Result<f64, ParseFloatError>[src]

Read a floating point number as f64.

pub fn is_empty(&self) -> bool[src]

Check if the reader is empty.

pub fn as_str(&self) -> &'a str[src]

Get the rest of the input.

Auto Trait Implementations

impl<'a> RefUnwindSafe for StringReader<'a>

impl<'a> Send for StringReader<'a>

impl<'a> Sync for StringReader<'a>

impl<'a> Unpin for StringReader<'a>

impl<'a> UnwindSafe for StringReader<'a>

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.