Type Alias winnow::stream::Str

source ·
pub type Str<'i> = &'i str;
Expand description

UTF-8 Stream

Trait Implementations§

source§

impl<'a> AsBStr for &'a str

source§

fn as_bstr(&self) -> &[u8]

Casts the input type to a byte slice
source§

impl<'a, 'b> Compare<&'b [u8]> for &'a str

source§

fn compare(&self, t: &'b [u8]) -> CompareResult

Compares self to another value for equality
source§

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

source§

fn compare(&self, t: &'b str) -> CompareResult

Compares self to another value for equality
source§

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 Default for &str

source§

fn default() -> &str

Creates an empty str

1.0.0 · source§

impl !Error for &str

1.30.0 · source§

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

👎Deprecated since 1.42.0: use the Display impl or to_string()
1.0.0 · source§

fn cause(&self) -> Option<&dyn Error>

👎Deprecated since 1.33.0: replaced by Error::source, which can support downcasting
source§

fn provide<'a>(&'a self, request: &mut Request<'a>)

🔬This is a nightly-only experimental API. (error_generic_member_access)
Provides type based access to context intended for error reports. Read more
source§

impl<'i, 's> FindSlice<&'s str> for &'i str

source§

fn find_slice(&self, substr: &'s str) -> Option<usize>

Returns the offset of the slice if it is found
source§

impl<'i> FindSlice<char> for &'i str

source§

fn find_slice(&self, substr: char) -> Option<usize>

Returns the offset of the slice if it is found
source§

impl<'a> Offset<&'a str> for &'a str

source§

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

source§

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

source§

fn parse_slice(&self) -> Option<R>

Succeeds if parse() succeededThe Read more
source§

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_next(&mut self, i: &mut I) -> PResult<<I as Stream>::Slice, E>

Take tokens from the Stream, turning it into the output Read more
source§

fn parse_peek(&mut self, input: I) -> IResult<I, O, E>

Take tokens from the Stream, turning it into the output Read more
source§

fn by_ref(&mut self) -> ByRef<'_, Self>where Self: Sized,

Treat &mut Self as a parser Read more
source§

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,

Discards the output of the Parser Read more
source§

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 more
source§

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,

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,

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>,

Applies a function returning a Result over the output of a parser. Read more
source§

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>,

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>,

Apply std::str::FromStr to the output of the parser Read more
source§

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,

If parsing fails, add context to the error Read more
source§

fn complete_err(self) -> CompleteErr<Self>where Self: Sized,

source§

fn err_into<E2>(self) -> ErrInto<Self, I, O, E, E2>where Self: Sized, E: Into<E2>,

Convert the parser’s error to another type using std::convert::From
source§

impl<'a, 'b> PartialEq<BStr> for &'a str

source§

fn eq(&self, other: &BStr) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, 'b> PartialEq<Bytes> for &'a str

source§

fn eq(&self, other: &Bytes) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.0.0 · source§

impl<'a, 'b> PartialEq<Cow<'a, str>> for &'b str

source§

fn eq(&self, other: &Cow<'a, str>) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &Cow<'a, str>) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.29.0 · source§

impl<'a> PartialEq<OsString> for &'a str

source§

fn eq(&self, other: &OsString) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

fn ne(&self, other: &Rhs) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
1.0.0 · source§

impl<'a, 'b> PartialEq<String> for &'a str

source§

fn eq(&self, other: &String) -> bool

This method tests for self and other values to be equal, and is used by ==.
source§

fn ne(&self, other: &String) -> bool

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<'a, 'b> PartialOrd<BStr> for &'a str

source§

fn partial_cmp(&self, other: &BStr) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

impl<'a, 'b> PartialOrd<Bytes> for &'a str

source§

fn partial_cmp(&self, other: &Bytes) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · source§

fn lt(&self, other: &Rhs) -> bool

This method tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · source§

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 more
1.0.0 · source§

fn gt(&self, other: &Rhs) -> bool

This method tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · source§

fn ge(&self, other: &Rhs) -> bool

This method tests greater than or equal to (for self and other) and is used by the >= operator. Read more
source§

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)

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)

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)

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)

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)

Removes the pattern from the back of haystack, if it matches.

§

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>

🔬This is a nightly-only experimental API. (pattern)
Constructs the associated searcher from self and the haystack to search in.
source§

impl<'a> SliceLen for &'a str

source§

fn slice_len(&self) -> usize

Calculates the input length, as indicated by its name, and the name of the trait itself
source§

impl<'i> Stream for &'i str

§

type Token = char

The smallest unit being parsed Read more
§

type Slice = &'i str

Sequence of Tokens Read more
§

type IterOffsets = CharIndices<'i>

Iterate with the offset from the current location
§

type Checkpoint = Checkpoint<&'i str>

A parse location within the stream
source§

fn iter_offsets(&self) -> Self::IterOffsets

Iterate with the offset from the current location
source§

fn eof_offset(&self) -> usize

Returns the offaet to the end of the input
source§

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,

Finds the offset of the next matching token
source§

fn offset_at(&self, tokens: usize) -> Result<usize, Needed>

Get the offset for the number of tokens into the stream Read more
source§

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

Save the current parse location within the stream
source§

fn reset(&mut self, checkpoint: Self::Checkpoint)

Revert the stream to a prior Self::Checkpoint Read more
source§

fn raw(&self) -> &dyn Debug

Return the inner-most stream
source§

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,

Split off a slice of tokens from the input
source§

fn finish(&mut self) -> Self::Slice

Advance to the end of the stream
source§

fn peek_finish(&self) -> (Self, Self::Slice)where Self: Clone,

Advance to the end of the stream
source§

impl<'a> StreamIsPartial for &'a str

§

type PartialState = ()

Whether the stream is currently partial or complete
source§

fn complete(&mut self) -> Self::PartialState

Mark the stream is complete
source§

fn restore_partial(&mut self, _state: Self::PartialState)

Restore the stream back to its previous state
source§

fn is_partial_supported() -> bool

Report whether the Stream is can ever be incomplete
source§

fn is_partial(&self) -> bool

Report whether the Stream is currently incomplete
1.72.0 · source§

impl<'a> TryFrom<&'a OsStr> for &'a str

source§

fn try_from( value: &'a OsStr ) -> Result<&'a str, <&'a str as TryFrom<&'a OsStr>>::Error>

Tries to convert an &OsStr to a &str.

use std::ffi::OsStr;

let os_str = OsStr::new("foo");
let as_str = <&str>::try_from(os_str).unwrap();
assert_eq!(as_str, "foo");
§

type Error = Utf8Error

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

impl<'a> UpdateSlice for &'a str

source§

fn update_slice(self, inner: Self::Slice) -> Self

Convert an Output type to be used as Stream