pub struct Caseless<T>(pub T);
Expand description
Mark a value as case-insensitive for ASCII characters
§Example
fn parser<'s>(s: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
Caseless("hello").parse_next(s)
}
assert_eq!(parser.parse_peek("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser.parse_peek("hello, World!"), Ok((", World!", "hello")));
assert_eq!(parser.parse_peek("HeLlo, World!"), Ok((", World!", "HeLlo")));
assert_eq!(parser.parse_peek("Some"), Err(ErrMode::Backtrack(InputError::new("Some", ErrorKind::Tag))));
assert_eq!(parser.parse_peek(""), Err(ErrMode::Backtrack(InputError::new("", ErrorKind::Tag))));
Tuple Fields§
§0: T
Implementations§
Trait Implementations§
source§impl<'a, 'b> Compare<Caseless<&'b [u8]>> for &'a [u8]
impl<'a, 'b> Compare<Caseless<&'b [u8]>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<&'b [u8]>) -> CompareResult
fn compare(&self, t: AsciiCaseless<&'b [u8]>) -> CompareResult
Compares self to another value for equality
source§impl<'a, 'b, const LEN: usize> Compare<Caseless<&'b [u8; LEN]>> for &'a [u8]
impl<'a, 'b, const LEN: usize> Compare<Caseless<&'b [u8; LEN]>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<&'b [u8; LEN]>) -> CompareResult
fn compare(&self, t: AsciiCaseless<&'b [u8; LEN]>) -> CompareResult
Compares self to another value for equality
source§impl<'a, 'b> Compare<Caseless<&'b str>> for &'a [u8]
impl<'a, 'b> Compare<Caseless<&'b str>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<&'b str>) -> CompareResult
fn compare(&self, t: AsciiCaseless<&'b str>) -> CompareResult
Compares self to another value for equality
source§impl<'a, 'b> Compare<Caseless<&'b str>> for &'a str
impl<'a, 'b> Compare<Caseless<&'b str>> for &'a str
source§fn compare(&self, t: AsciiCaseless<&'b str>) -> CompareResult
fn compare(&self, t: AsciiCaseless<&'b str>) -> CompareResult
Compares self to another value for equality
source§impl<'a, const LEN: usize> Compare<Caseless<[u8; LEN]>> for &'a [u8]
impl<'a, const LEN: usize> Compare<Caseless<[u8; LEN]>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<[u8; LEN]>) -> CompareResult
fn compare(&self, t: AsciiCaseless<[u8; LEN]>) -> CompareResult
Compares self to another value for equality
source§impl<'a> Compare<Caseless<char>> for &'a [u8]
impl<'a> Compare<Caseless<char>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<char>) -> CompareResult
fn compare(&self, t: AsciiCaseless<char>) -> CompareResult
Compares self to another value for equality
source§impl<'a> Compare<Caseless<char>> for &'a str
impl<'a> Compare<Caseless<char>> for &'a str
source§fn compare(&self, t: AsciiCaseless<char>) -> CompareResult
fn compare(&self, t: AsciiCaseless<char>) -> CompareResult
Compares self to another value for equality
source§impl<'a> Compare<Caseless<u8>> for &'a [u8]
impl<'a> Compare<Caseless<u8>> for &'a [u8]
source§fn compare(&self, t: AsciiCaseless<u8>) -> CompareResult
fn compare(&self, t: AsciiCaseless<u8>) -> CompareResult
Compares self to another value for equality
source§impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8]>
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8]>
This is a shortcut for literal
.
§Example
use winnow::ascii::Caseless;
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((Caseless(&"hello"[..]), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"hello, World!"[..]), Ok((&b", World!"[..], &b"hello"[..])));
assert_eq!(parser.parse_peek(&b"HeLlo, World!"[..]), Ok((&b", World!"[..], &b"HeLlo"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));
source§fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
Parse all of
input
, generating O
from itsource§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 default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Produce a type’s default 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>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
Convert the parser’s output to another type using
std::convert::From
Read moresource§fn recognize(self) -> Take<Self, I, O, E>
fn recognize(self) -> Take<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::take
Replaced with
Parser::take
source§fn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Produce the consumed input with the output Read more
source§fn with_recognized(self) -> WithTaken<Self, I, O, E>
fn with_recognized(self) -> WithTaken<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::with_taken
Replaced with
Parser::with_taken
source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
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>
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, 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>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, 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>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
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>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
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>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
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<'s, I, E: ParserError<I>, const N: usize> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8; N]>
impl<'s, I, E: ParserError<I>, const N: usize> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s [u8; N]>
This is a shortcut for literal
.
§Example
use winnow::ascii::Caseless;
fn parser<'s>(s: &mut &'s [u8]) -> PResult<&'s [u8], InputError<&'s [u8]>> {
alt((Caseless(b"hello"), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek(&b"Hello, World!"[..]), Ok((&b", World!"[..], &b"Hello"[..])));
assert_eq!(parser.parse_peek(&b"hello, World!"[..]), Ok((&b", World!"[..], &b"hello"[..])));
assert_eq!(parser.parse_peek(&b"HeLlo, World!"[..]), Ok((&b", World!"[..], &b"HeLlo"[..])));
assert_eq!(parser.parse_peek(&b"Something"[..]), Ok((&b"hing"[..], &b"Somet"[..])));
assert_eq!(parser.parse_peek(&b"Some"[..]), Err(ErrMode::Backtrack(InputError::new(&b"Some"[..], ErrorKind::Slice))));
assert_eq!(parser.parse_peek(&b""[..]), Err(ErrMode::Backtrack(InputError::new(&b""[..], ErrorKind::Slice))));
source§fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
Parse all of
input
, generating O
from itsource§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 default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Produce a type’s default 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>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
Convert the parser’s output to another type using
std::convert::From
Read moresource§fn recognize(self) -> Take<Self, I, O, E>
fn recognize(self) -> Take<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::take
Replaced with
Parser::take
source§fn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Produce the consumed input with the output Read more
source§fn with_recognized(self) -> WithTaken<Self, I, O, E>
fn with_recognized(self) -> WithTaken<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::with_taken
Replaced with
Parser::with_taken
source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
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>
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, 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>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, 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>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
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>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
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>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
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<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s str>
impl<'s, I, E: ParserError<I>> Parser<I, <I as Stream>::Slice, E> for Caseless<&'s str>
This is a shortcut for literal
.
§Example
fn parser<'s>(s: &mut &'s str) -> PResult<&'s str, InputError<&'s str>> {
alt((Caseless("hello"), take(5usize))).parse_next(s)
}
assert_eq!(parser.parse_peek("Hello, World!"), Ok((", World!", "Hello")));
assert_eq!(parser.parse_peek("hello, World!"), Ok((", World!", "hello")));
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(&mut self, input: I) -> Result<O, ParseError<I, E>>
fn parse(&mut self, input: I) -> Result<O, ParseError<I, E>>
Parse all of
input
, generating O
from itsource§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 default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
fn default_value<O2>(self) -> DefaultValue<Self, I, O, O2, E>
Produce a type’s default 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>
fn output_into<O2>(self) -> OutputInto<Self, I, O, O2, E>
Convert the parser’s output to another type using
std::convert::From
Read moresource§fn recognize(self) -> Take<Self, I, O, E>
fn recognize(self) -> Take<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::take
Replaced with
Parser::take
source§fn with_taken(self) -> WithTaken<Self, I, O, E>
fn with_taken(self) -> WithTaken<Self, I, O, E>
Produce the consumed input with the output Read more
source§fn with_recognized(self) -> WithTaken<Self, I, O, E>
fn with_recognized(self) -> WithTaken<Self, I, O, E>
👎Deprecated since 0.6.14: Replaced with
Parser::with_taken
Replaced with
Parser::with_taken
source§fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
fn map<G, O2>(self, map: G) -> Map<Self, G, I, O, O2, E>
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>
fn try_map<G, O2, E2>(self, map: G) -> TryMap<Self, G, I, O, O2, E, 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>
fn verify_map<G, O2>(self, map: G) -> VerifyMap<Self, G, I, O, O2, E>
source§fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, O2, E>
fn flat_map<G, H, O2>(self, map: G) -> FlatMap<Self, G, H, I, O, 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>
fn parse_to<O2>(self) -> ParseTo<Self, I, O, O2, E>
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>
fn verify<G, O2>(self, filter: G) -> Verify<Self, G, I, O, O2, E>
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>
fn context<C>(self, context: C) -> Context<Self, I, O, E, C>
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,
impl<T: Copy> Copy for Caseless<T>
Auto Trait Implementations§
impl<T> Freeze for Caseless<T>where
T: Freeze,
impl<T> RefUnwindSafe for Caseless<T>where
T: RefUnwindSafe,
impl<T> Send for Caseless<T>where
T: Send,
impl<T> Sync for Caseless<T>where
T: Sync,
impl<T> Unpin for Caseless<T>where
T: Unpin,
impl<T> UnwindSafe for Caseless<T>where
T: UnwindSafe,
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