pub type Str<'i> = &'i str;
Expand description
UTF-8 Stream
Trait Implementations§
source§impl<'a, 'b> Compare<&'b [u8]> for &'a str
impl<'a, 'b> Compare<&'b [u8]> for &'a str
source§fn compare(&self, t: &'b [u8]) -> CompareResult
fn compare(&self, t: &'b [u8]) -> CompareResult
Compares self to another value for equality
source§fn compare_no_case(&self, t: &'b [u8]) -> CompareResult
fn compare_no_case(&self, t: &'b [u8]) -> CompareResult
Compares self to another value for equality
independently of the case. Read more
source§impl<'a, 'b> Compare<&'b str> for &'a str
impl<'a, 'b> Compare<&'b str> for &'a str
source§fn compare(&self, t: &'b str) -> CompareResult
fn compare(&self, t: &'b str) -> CompareResult
Compares self to another value for equality
source§fn compare_no_case(&self, t: &'b str) -> CompareResult
fn compare_no_case(&self, t: &'b str) -> CompareResult
Compares self to another value for equality
independently of the case. Read more
1.0.0 · source§impl !Error for &str
impl !Error for &str
1.30.0 · source§fn source(&self) -> Option<&(dyn Error + 'static)>
fn source(&self) -> Option<&(dyn Error + 'static)>
The lower-level source of this error, if any. Read more
1.0.0 · source§fn description(&self) -> &str
fn description(&self) -> &str
👎Deprecated since 1.42.0: use the Display impl or to_string()
source§impl<'a> Offset<&'a str> for &'a str
impl<'a> Offset<&'a str> for &'a str
source§fn offset_from(&self, start: &Self) -> usize
fn offset_from(&self, start: &Self) -> usize
Offset between the first byte of
start
and the first byte of self
source§impl<'a> Offset<<&'a str as Stream>::Checkpoint> for &'a str
impl<'a> Offset<<&'a str as Stream>::Checkpoint> for &'a str
source§fn offset_from(&self, other: &<&'a str as Stream>::Checkpoint) -> usize
fn offset_from(&self, other: &<&'a str as Stream>::Checkpoint) -> usize
Offset between the first byte of
start
and the first byte of self
source§impl<'a, R: FromStr> ParseSlice<R> for &'a str
impl<'a, R: FromStr> ParseSlice<R> for &'a str
source§fn parse_slice(&self) -> Option<R>
fn parse_slice(&self) -> Option<R>
Succeeds if
parse()
succeededThe Read moresource§impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s strwhere
I: Compare<&'s str> + StreamIsPartial + Stream,
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for &'s strwhere I: Compare<&'s str> + StreamIsPartial + Stream,
This is a shortcut for tag
.
Example
fn parser<'s>(s: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
alt(("Hello", take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser.parse_peek("Something"), Ok(("hing", "Somet")));
assert_eq!(parser.parse_peek("Some"), Err(ErrMode::Backtrack(InputError::new("Some", ErrorKind::Slice))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Slice))));
source§fn parse_peek(&mut self, input: I) -> IResult<I, O, E>
fn parse_peek(&mut self, input: I) -> IResult<I, O, E>
source§fn by_ref(&mut self) -> ByRef<'_, Self>where
Self: Sized,
fn by_ref(&mut self) -> ByRef<'_, Self>where Self: Sized,
Treat
&mut Self
as a parser Read moresource§fn value<O2>(self, val: O2) -> Value<Self, I, O, O2, E>where
Self: Sized,
O2: Clone,
fn value<O2>(self, val: O2) -> Value<Self, I, O, O2, E>where Self: Sized, O2: Clone,
Produce the provided value Read more
source§fn void(self) -> Void<Self, I, O, E>where
Self: Sized,
fn void(self) -> Void<Self, I, O, E>where Self: Sized,
Discards the output of the
Parser
Read moresource§fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>where
Self: Sized,
O: Into<O2>,
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>where Self: Sized, O: Into<O2>,
Convert the parser’s output to another type using
std::convert::From
Read moresource§fn recognize(self) -> Recognize<Self, I, O, E>where
Self: Sized,
I: Stream,
fn recognize(self) -> Recognize<Self, I, O, E>where Self: Sized, I: Stream,
Produce the consumed input as produced value. Read more
source§fn with_recognized(self) -> WithRecognized<Self, I, O, E>where
Self: Sized,
I: Stream,
fn with_recognized(self) -> WithRecognized<Self, I, O, E>where Self: Sized, I: Stream,
Produce the consumed input with the output Read more
source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>where
G: Fn(O) -> O2,
Self: Sized,
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>where G: Fn(O) -> O2, Self: Sized,
Maps a function over the output of a parser Read more
source§fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>where
Self: Sized,
G: FnMut(O) -> Result<O2, E2>,
I: Stream,
E: FromExternalError<I, E2>,
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, E2>where Self: Sized, G: FnMut(O) -> Result<O2, E2>, I: Stream, E: FromExternalError<I, E2>,
Applies a function returning a
Result
over the output of a parser. Read moresource§fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>where
Self: Sized,
G: FnMut(O) -> Option<O2>,
I: Stream,
E: ParserError<I>,
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>where Self: Sized, G: FnMut(O) -> Option<O2>, I: Stream, E: ParserError<I>,
source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>where
Self: Sized,
G: FnMut(O) -> H,
H: Parser<I, O2, E>,
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>where Self: Sized, G: FnMut(O) -> H, H: Parser<I, O2, E>,
Creates a parser from the output of this one Read more
source§fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>where
Self: Sized,
I: Stream,
O: ParseSlice<O2>,
E: ParserError<I>,
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>where Self: Sized, I: Stream, O: ParseSlice<O2>, E: ParserError<I>,
Apply
std::str::FromStr
to the output of the parser Read moresource§fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>where
Self: Sized,
G: Fn(&O2) -> bool,
I: Stream,
O: Borrow<O2>,
O2: ?Sized,
E: ParserError<I>,
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>where Self: Sized, G: Fn(&O2) -> bool, I: Stream, O: Borrow<O2>, O2: ?Sized, E: ParserError<I>,
Returns the output of the child parser if it satisfies a verification function. Read more
source§fn context<C>(self, context: C) -> Context<Self, I, O, E, C>where
Self: Sized,
I: Stream,
E: AddContext<I, C>,
C: Clone + Debug,
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>where Self: Sized, I: Stream, E: AddContext<I, C>, C: Clone + Debug,
If parsing fails, add context to the error Read more
source§fn complete_err(self) -> CompleteErr<Self>where
Self: Sized,
fn complete_err(self) -> CompleteErr<Self>where Self: Sized,
source§impl<'a, 'b> PartialEq<BStr> for &'a str
impl<'a, 'b> PartialEq<BStr> for &'a str
source§impl<'a, 'b> PartialEq<Bytes> for &'a str
impl<'a, 'b> PartialEq<Bytes> for &'a str
1.0.0 · source§impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str
impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str
1.29.0 · source§impl<'a> PartialEq<OsString> for &'a str
impl<'a> PartialEq<OsString> for &'a str
source§impl<'a, 'b> PartialOrd<BStr> for &'a str
impl<'a, 'b> PartialOrd<BStr> for &'a str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> PartialOrd<Bytes> for &'a str
impl<'a, 'b> PartialOrd<Bytes> for &'a str
1.0.0 · source§fn le(&self, other: &Rhs) -> bool
fn le(&self, other: &Rhs) -> bool
This method tests less than or equal to (for
self
and other
) and is used by the <=
operator. Read moresource§impl<'a, 'b> Pattern<'a> for &'b str
impl<'a, 'b> Pattern<'a> for &'b str
Non-allocating substring search.
Will handle the pattern ""
as returning empty matches at each character
boundary.
Examples
assert_eq!("Hello world".find("world"), Some(6));
source§fn is_prefix_of(self, haystack: &'a str) -> bool
🔬This is a nightly-only experimental API. (pattern
)
fn is_prefix_of(self, haystack: &'a str) -> bool
pattern
)Checks whether the pattern matches at the front of the haystack.
source§fn is_contained_in(self, haystack: &'a str) -> bool
🔬This is a nightly-only experimental API. (pattern
)
fn is_contained_in(self, haystack: &'a str) -> bool
pattern
)Checks whether the pattern matches anywhere in the haystack
source§fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str>
🔬This is a nightly-only experimental API. (pattern
)
fn strip_prefix_of(self, haystack: &'a str) -> Option<&'a str>
pattern
)Removes the pattern from the front of haystack, if it matches.
source§fn is_suffix_of(self, haystack: &'a str) -> bool
🔬This is a nightly-only experimental API. (pattern
)
fn is_suffix_of(self, haystack: &'a str) -> bool
pattern
)Checks whether the pattern matches at the back of the haystack.
source§fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str>
🔬This is a nightly-only experimental API. (pattern
)
fn strip_suffix_of(self, haystack: &'a str) -> Option<&'a str>
pattern
)Removes the pattern from the back of haystack, if it matches.
§type Searcher = StrSearcher<'a, 'b>
type Searcher = StrSearcher<'a, 'b>
🔬This is a nightly-only experimental API. (
pattern
)Associated searcher for this pattern
source§fn into_searcher(self, haystack: &'a str) -> StrSearcher<'a, 'b>
fn into_searcher(self, haystack: &'a str) -> StrSearcher<'a, 'b>
🔬This is a nightly-only experimental API. (
pattern
)Constructs the associated searcher from
self
and the haystack
to search in.source§impl<'i> Stream for &'i str
impl<'i> Stream for &'i str
§type IterOffsets = CharIndices<'i>
type IterOffsets = CharIndices<'i>
Iterate with the offset from the current location
§type Checkpoint = Checkpoint<&'i str>
type Checkpoint = Checkpoint<&'i str>
A parse location within the stream
source§fn iter_offsets(&self) -> Self::IterOffsets
fn iter_offsets(&self) -> Self::IterOffsets
Iterate with the offset from the current location
source§fn eof_offset(&self) -> usize
fn eof_offset(&self) -> usize
Returns the offaet to the end of the input
source§fn next_token(&mut self) -> Option<Self::Token>
fn next_token(&mut self) -> Option<Self::Token>
Split off the next token from the input
source§fn offset_for<P>(&self, predicate: P) -> Option<usize>where
P: Fn(Self::Token) -> bool,
fn offset_for<P>(&self, predicate: P) -> Option<usize>where P: Fn(Self::Token) -> bool,
Finds the offset of the next matching token
source§fn offset_at(&self, tokens: usize) -> Result<usize, Needed>
fn offset_at(&self, tokens: usize) -> Result<usize, Needed>
Get the offset for the number of
tokens
into the stream Read moresource§fn next_slice(&mut self, offset: usize) -> Self::Slice
fn next_slice(&mut self, offset: usize) -> Self::Slice
Split off a slice of tokens from the input Read more
source§fn checkpoint(&self) -> Self::Checkpoint
fn checkpoint(&self) -> Self::Checkpoint
Save the current parse location within the stream
source§fn reset(&mut self, checkpoint: Self::Checkpoint)
fn reset(&mut self, checkpoint: Self::Checkpoint)
Revert the stream to a prior
Self::Checkpoint
Read moresource§fn peek_token(&self) -> Option<(Self, Self::Token)>where
Self: Clone,
fn peek_token(&self) -> Option<(Self, Self::Token)>where Self: Clone,
Split off the next token from the input
source§fn peek_slice(&self, offset: usize) -> (Self, Self::Slice)where
Self: Clone,
fn peek_slice(&self, offset: usize) -> (Self, Self::Slice)where Self: Clone,
Split off a slice of tokens from the input
source§fn peek_finish(&self) -> (Self, Self::Slice)where
Self: Clone,
fn peek_finish(&self) -> (Self, Self::Slice)where Self: Clone,
Advance to the end of the stream
source§impl<'a> StreamIsPartial for &'a str
impl<'a> StreamIsPartial for &'a str
§type PartialState = ()
type PartialState = ()
Whether the stream is currently partial or complete
source§fn complete(&mut self) -> Self::PartialState
fn complete(&mut self) -> Self::PartialState
Mark the stream is complete
source§fn restore_partial(&mut self, _state: Self::PartialState)
fn restore_partial(&mut self, _state: Self::PartialState)
Restore the stream back to its previous state
source§fn is_partial_supported() -> bool
fn is_partial_supported() -> bool
Report whether the
Stream
is can ever be incompletesource§fn is_partial(&self) -> bool
fn is_partial(&self) -> bool
Report whether the
Stream
is currently incomplete1.72.0 · source§impl<'a> TryFrom<&'a OsStr> for &'a str
impl<'a> TryFrom<&'a OsStr> for &'a str
source§impl<'a> UpdateSlice for &'a str
impl<'a> UpdateSlice for &'a str
source§fn update_slice(self, inner: Self::Slice) -> Self
fn update_slice(self, inner: Self::Slice) -> Self
Convert an
Output
type to be used as Stream