Struct scan_rules::input::StrCursor
[−]
[src]
pub struct StrCursor<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord { // some fields omitted }
Basic cursor implementation wrapping a string slice.
The Cmp
parameter can be used to control the string comparison logic used.
Methods
impl<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
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
impl<'a, Cmp: Debug, Space: Debug, Word: Debug> Debug for StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
impl<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> Copy for StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
impl<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> Clone for StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
fn clone(&self) -> Self
Returns a copy of the value. Read more
fn clone_from(&mut self, source: &Self)
1.0.0
Performs copy-assignment from source
. Read more
impl<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> ScanCursor<'a> for StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
type ScanInput = Self
Corresponding scan input type.
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".
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
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.
fn try_match_literal(self, lit: &str) -> Result<Self, (ScanError, Self)>
Match the provided literal term against the input. Read more
fn as_str(self) -> &'a str
Returns the remaining input as a string slice.
fn offset(&self) -> usize
Returns the number of bytes consumed by this cursor since its creation.
impl<'a, Cmp = ExactCompare, Space = IgnoreSpace, Word = Wordish> ScanInput<'a> for StrCursor<'a, Cmp, Space, Word> where Cmp: StrCompare, Space: SkipSpace, Word: SliceWord
[src]
type ScanCursor = Self
Corresponding cursor type.
type StrCompare = Cmp
Marker type used to do string comparisons.
fn as_str(&self) -> &'a str
Get the contents of the input as a string slice.
fn from_subslice(&self, subslice: &'a str) -> Self
Create a new input from a subslice of this input's contents. Read more
fn to_cursor(&self) -> Self::ScanCursor
Turn the input into an independent cursor, suitable for feeding back into a user-facing scanning macro.