Struct yew_ansi::CharCursor
source · pub struct CharCursor<'a> { /* private fields */ }
Expand description
Cursor for characters in a string slice.
Implementations§
source§impl<'a> CharCursor<'a>
impl<'a> CharCursor<'a>
sourcepub fn new(s: &'a str) -> Self
pub fn new(s: &'a str) -> Self
Create a cursor for the given slice. The cursor starts at the start of the slice.
sourcepub fn position(&self) -> usize
pub fn position(&self) -> usize
Get the cursor’s position in the slice. This will always point to a valid char boundary.
sourcepub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&'a I::Output>
pub fn get<I: SliceIndex<str>>(&self, i: I) -> Option<&'a I::Output>
Index the contained string slice. The index isn’t bound by the cursor’s position, only by the underlying slice.
sourcepub fn remainder(&self) -> &'a str
pub fn remainder(&self) -> &'a str
Get a string slice containing all the characters following the current position.
sourcepub fn peek_char(&self, expected: char) -> bool
pub fn peek_char(&self, expected: char) -> bool
Check if the next character matches the expected one. This doesn’t advance the cursor’s position.
sourcepub fn read_char(&mut self, expected: char) -> Option<char>
pub fn read_char(&mut self, expected: char) -> Option<char>
Read the next character and advance the cursor only if it matches the expected one.
Returns None
if the character didn’t match.
sourcepub fn read_while(&mut self, f: impl FnMut(char) -> bool)
pub fn read_while(&mut self, f: impl FnMut(char) -> bool)
Advance the cursor while the given function returns true
.
The cursor won’t advance if the function returns false
.
Trait Implementations§
source§impl<'a> Clone for CharCursor<'a>
impl<'a> Clone for CharCursor<'a>
source§fn clone(&self) -> CharCursor<'a>
fn clone(&self) -> CharCursor<'a>
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moreAuto Trait Implementations§
impl<'a> RefUnwindSafe for CharCursor<'a>
impl<'a> Send for CharCursor<'a>
impl<'a> Sync for CharCursor<'a>
impl<'a> Unpin for CharCursor<'a>
impl<'a> UnwindSafe for CharCursor<'a>
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
source§impl<T> Instrument for T
impl<T> Instrument for T
source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
source§impl<T> IntoPropValue<Option<T>> for T
impl<T> IntoPropValue<Option<T>> for T
source§fn into_prop_value(self) -> Option<T>
fn into_prop_value(self) -> Option<T>
Convert
self
to a value of a Properties
struct.source§impl<T> IntoPropValue<T> for T
impl<T> IntoPropValue<T> for T
source§fn into_prop_value(self) -> T
fn into_prop_value(self) -> T
Convert
self
to a value of a Properties
struct.