Skip to main content

CharacterReader

Struct CharacterReader 

Source
pub struct CharacterReader<'a> { /* private fields */ }
Expand description

A forward-only reader over a string.

Implementations§

Source§

impl CharacterReader<'_>

Source

pub fn parse_arguments( &mut self, open: char, close: char, ) -> Result<Vec<String>, ExpressionParseException>

Parses a list of arguments enclosed in open/close and separated by ,. The reader must be positioned on open.

Source

pub fn parse_arguments_with_delimiter( &mut self, open: char, close: char, delimiter: char, ) -> Result<Vec<String>, ExpressionParseException>

Parses a list of arguments enclosed in open/close and separated by delimiter. The reader must be positioned on open.

Source§

impl<'a> CharacterReader<'a>

Source

pub fn new(s: &'a str) -> Self

Creates a reader positioned at the start of s.

Source

pub fn end(&self) -> bool

Gets a value indicating whether the whole input has been consumed.

Source

pub fn peek(&self) -> Option<char>

Gets the next character without consuming it, or None at the end.

Source

pub fn position(&self) -> i32

Gets the number of characters consumed so far.

As upstream, Self::skip does not advance the position.

Source

pub fn take(&mut self) -> Option<char>

Consumes and returns the next character, or returns None at the end.

Source

pub fn skip_whitespace(&mut self)

Consumes leading white space.

Source

pub fn take_if(&mut self, c: char) -> bool

Consumes the next character if it equals c.

Source

pub fn take_if_str(&mut self, s: &str) -> bool

Consumes s if the remaining input starts with it.

Source

pub fn take_if_fn(&mut self, condition: impl Fn(char) -> bool) -> bool

Consumes the next character if it satisfies condition.

Source

pub fn take_until(&mut self, c: char) -> &'a str

Consumes and returns everything up to (not including) the first c, or the rest of the input when c does not occur.

Source

pub fn take_while(&mut self, condition: impl Fn(char) -> bool) -> &'a str

Consumes and returns the longest prefix whose characters all satisfy condition.

Source

pub fn try_peek(&self, count: usize) -> &'a str

Returns the next count characters without consuming them, or an empty string when fewer than count characters remain.

Source

pub fn peek_whitespace(&self) -> &'a str

Returns the leading white space without consuming it.

Source

pub fn skip(&mut self, count: usize)

Consumes count characters without advancing Self::position (as upstream).

§Panics

Panics when fewer than count characters remain; callers skip only what they have peeked.

Source§

impl<'a> CharacterReader<'a>

Source

pub fn parse_identifier(&mut self) -> &'a str

Parses an identifier: a letter or _ followed by letters, _, marks, connector punctuation, format characters and decimal digits. Returns an empty string (consuming nothing) when the input does not start with an identifier.

Source

pub fn parse_type_identifier(&mut self) -> &'a str

Parses an identifier that may name a nested type, e.g. “Outer+Inner”.

Source

pub fn parse_number(&mut self) -> &'a str

Parses a run of decimal digits (possibly empty).

Source§

impl CharacterReader<'_>

Source

pub fn check_keyword(&self, keyword: &str) -> bool

Checks whether the input continues with optional white space followed by keyword, without consuming anything.

Source

pub fn take_if_keyword(&mut self, keyword: &str) -> bool

Consumes optional white space followed by keyword if the input continues with it.

As upstream, the consumed characters are skipped without advancing CharacterReader::position.

Source§

impl<'a> CharacterReader<'a>

Source

pub fn parse_style_class(&mut self) -> &'a str

Parses a style class name: an identifier that may also contain -. Returns an empty string (consuming nothing) when the input does not start with a class name.

Trait Implementations§

Source§

impl<'a> Clone for CharacterReader<'a>

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<'a> Debug for CharacterReader<'a>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more

Auto Trait Implementations§

§

impl<'a> Freeze for CharacterReader<'a>

§

impl<'a> RefUnwindSafe for CharacterReader<'a>

§

impl<'a> Send for CharacterReader<'a>

§

impl<'a> Sync for CharacterReader<'a>

§

impl<'a> Unpin for CharacterReader<'a>

§

impl<'a> UnsafeUnpin for CharacterReader<'a>

§

impl<'a> UnwindSafe for CharacterReader<'a>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> ClassDefaults for T
where T: ?Sized,

Source§

fn static_constructor()

The static constructor of a type: work done once per thread, after the properties of the type are registered and before its first instance exists (class handlers, affects_render, metadata overrides). Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.