Struct StrCursor

Source
pub struct StrCursor<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,
{ /* private fields */ }
Expand description

Basic cursor implementation wrapping a string slice.

The Cmp parameter can be used to control the string comparison logic used.

Implementations§

Source§

impl<'a, Cmp, Space, Word> StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Source

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

Construct a new StrCursor with a specific offset.

The offset is logically the number of bytes which have already been consumed from the original input; these already-consumed bytes must not be included in slice.

Trait Implementations§

Source§

impl<'a, Cmp, Space, Word> Clone for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl<'a, Cmp, Space, Word> Debug for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare + Debug, Space: SkipSpace + Debug, Word: SliceWord + Debug,

Source§

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

Formats the value using the given formatter. Read more
Source§

impl<'a, Cmp, Space, Word> ScanCursor<'a> for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Source§

type ScanInput = StrCursor<'a, Cmp, Space, Word>

Corresponding scan input type.
Source§

fn try_end(self) -> Result<(), (ScanError, Self)>

Assert that the input has been exhausted, or that the current position is a valid place to “stop”.
Source§

fn try_scan<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
where F: FnOnce(Self::ScanInput) -> Result<(Out, usize), ScanError>,

Scan a value from the current position. The closure will be called with all available input, and is expected to return either the scanned value, and the number of bytes of input consumed, or a reason why scanning failed. Read more
Source§

fn try_scan_raw<F, Out>(self, f: F) -> Result<(Out, Self), (ScanError, Self)>
where F: FnOnce(Self::ScanInput) -> Result<(Out, usize), ScanError>,

Performs the same task as try_scan, except that it does not perform whitespace stripping.
Source§

fn try_match_literal(self, lit: &str) -> Result<Self, (ScanError, Self)>

Match the provided literal term against the input. Read more
Source§

fn as_str(self) -> &'a str

Returns the remaining input as a string slice.
Source§

fn offset(&self) -> usize

Returns the number of bytes consumed by this cursor since its creation.
Source§

impl<'a, Cmp, Space, Word> ScanInput<'a> for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Source§

type ScanCursor = StrCursor<'a, Cmp, Space, Word>

Corresponding cursor type.
Source§

type StrCompare = Cmp

Marker type used to do string comparisons.
Source§

fn as_str(&self) -> &'a str

Get the contents of the input as a string slice.
Source§

fn from_subslice(&self, subslice: &'a str) -> Self

Create a new input from a subslice of this input’s contents. Read more
Source§

fn to_cursor(&self) -> Self::ScanCursor

Turn the input into an independent cursor, suitable for feeding back into a user-facing scanning macro.
Source§

impl<'a, Cmp, Space, Word> Copy for StrCursor<'a, Cmp, Space, Word>
where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord,

Auto Trait Implementations§

§

impl<'a, Cmp, Space, Word> Freeze for StrCursor<'a, Cmp, Space, Word>

§

impl<'a, Cmp, Space, Word> RefUnwindSafe for StrCursor<'a, Cmp, Space, Word>
where Cmp: RefUnwindSafe, Space: RefUnwindSafe, Word: RefUnwindSafe,

§

impl<'a, Cmp, Space, Word> Send for StrCursor<'a, Cmp, Space, Word>
where Cmp: Send, Space: Send, Word: Send,

§

impl<'a, Cmp, Space, Word> Sync for StrCursor<'a, Cmp, Space, Word>
where Cmp: Sync, Space: Sync, Word: Sync,

§

impl<'a, Cmp, Space, Word> Unpin for StrCursor<'a, Cmp, Space, Word>
where Cmp: Unpin, Space: Unpin, Word: Unpin,

§

impl<'a, Cmp, Space, Word> UnwindSafe for StrCursor<'a, Cmp, Space, Word>
where Cmp: UnwindSafe, Space: UnwindSafe, Word: UnwindSafe,

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> 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<'a, T> IntoScanCursor<'a> for T
where T: 'a + ScanCursor<'a>,

Source§

type Output = T

The corresponding scannable cursor type.
Source§

fn into_scan_cursor(self) -> <T as IntoScanCursor<'a>>::Output

Convert this into a scannable cursor.
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 = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.