diff --git a/src/ascii/mod.rs b/src/ascii/mod.rs index 73e6b97e..9fafc32f 100644 --- a/src/ascii/mod.rs +++ b/src/ascii/mod.rs @@ -1327,6 +1327,7 @@ where } #[allow(clippy::trait_duplication_in_bounds)] // HACK: clippy 1.64.0 bug +#[allow(deprecated)] fn recognize_float_or_exceptions>( input: &mut I, ) -> PResult<::Slice, E> diff --git a/src/combinator/mod.rs b/src/combinator/mod.rs index f3e73cb2..542b156a 100644 --- a/src/combinator/mod.rs +++ b/src/combinator/mod.rs @@ -10,8 +10,7 @@ //! |---|---|---|---|---|---| //! | [`one_of`][crate::token::one_of] | `one_of(['a', 'b', 'c'])` | `"abc"` | `"bc"` | `Ok('a')` |Matches one of the provided characters (works with non ASCII characters too)| //! | [`none_of`][crate::token::none_of] | `none_of(['a', 'b', 'c'])` | `"xyab"` | `"yab"` | `Ok('x')` |Matches anything but the provided characters| -//! | [`tag`][crate::token::tag] | `"hello"` | `"hello world"` | `" world"` | `Ok("hello")` |Recognizes a specific suite of characters or bytes| -//! | [`tag_no_case`][crate::token::tag_no_case] | `tag_no_case("hello")` | `"HeLLo World"` | `" World"` | `Ok("HeLLo")` |Case insensitive comparison. Note that case insensitive comparison is not well defined for unicode, and that you might have bad surprises| +//! | [`tag`][crate::token::tag] | `"hello"` | `"hello world"` | `" world"` | `Ok("hello")` |Recognizes a specific suite of characters or bytes (see also [`Caseless`][crate::ascii::Caseless])| //! | [`take`][crate::token::take] | `take(4)` | `"hello"` | `"o"` | `Ok("hell")` |Takes a specific number of bytes or characters| //! | [`take_while`][crate::token::take_while] | `take_while(0.., is_alphabetic)` | `"abc123"` | `"123"` | `Ok("abc")` |Returns the longest list of bytes for which the provided pattern matches.| //! | [`take_till0`][crate::token::take_till0] | `take_till0(is_alphabetic)` | `"123abc"` | `"abc"` | `Ok("123")` |Returns the longest list of bytes or characters until the provided pattern matches. `take_till1` does the same, but must return at least one character. This is the reverse behaviour from `take_while`: `take_till(f)` is equivalent to `take_while(0.., \|c\| !f(c))`| diff --git a/src/stream/mod.rs b/src/stream/mod.rs index a144ddff..8191bcd9 100644 --- a/src/stream/mod.rs +++ b/src/stream/mod.rs @@ -1589,6 +1589,7 @@ pub trait Compare { /// by lowercasing both strings and comparing /// the result. This is a temporary solution until /// a better one appears + #[deprecated(since = "0.5.20", note = "Replaced with `compare(ascii::Caseless(_))`")] fn compare_no_case(&self, t: T) -> CompareResult; } @@ -1617,6 +1618,7 @@ impl<'a, 'b> Compare<&'b [u8]> for &'a [u8] { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: &'b [u8]) -> CompareResult { self.compare(AsciiCaseless(t)) } @@ -1639,6 +1641,7 @@ impl<'a, 'b> Compare> for &'a [u8] { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<&'b [u8]>) -> CompareResult { self.compare(t) } @@ -1651,6 +1654,7 @@ impl<'a, const LEN: usize> Compare<[u8; LEN]> for &'a [u8] { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: [u8; LEN]) -> CompareResult { self.compare_no_case(&t[..]) } @@ -1663,6 +1667,7 @@ impl<'a, const LEN: usize> Compare> for &'a [u8] { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<[u8; LEN]>) -> CompareResult { self.compare_no_case(AsciiCaseless(&t.0[..])) } @@ -1675,6 +1680,7 @@ impl<'a, 'b, const LEN: usize> Compare<&'b [u8; LEN]> for &'a [u8] { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: &'b [u8; LEN]) -> CompareResult { self.compare_no_case(&t[..]) } @@ -1687,6 +1693,7 @@ impl<'a, 'b, const LEN: usize> Compare> for &'a [u8 } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<&'b [u8; LEN]>) -> CompareResult { self.compare_no_case(AsciiCaseless(&t.0[..])) } @@ -1698,6 +1705,7 @@ impl<'a, 'b> Compare<&'b str> for &'a [u8] { self.compare(t.as_bytes()) } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: &'b str) -> CompareResult { self.compare_no_case(t.as_bytes()) } @@ -1709,6 +1717,7 @@ impl<'a, 'b> Compare> for &'a [u8] { self.compare(AsciiCaseless(t.0.as_bytes())) } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<&'b str>) -> CompareResult { self.compare_no_case(AsciiCaseless(t.0.as_bytes())) } @@ -1721,6 +1730,7 @@ impl<'a, 'b> Compare<&'b str> for &'a str { } #[inline] + #[allow(deprecated)] fn compare_no_case(&self, t: &'b str) -> CompareResult { self.compare(AsciiCaseless(t)) } @@ -1747,6 +1757,7 @@ impl<'a, 'b> Compare> for &'a str { } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<&'b str>) -> CompareResult { self.compare(t) } @@ -1758,6 +1769,7 @@ impl<'a, 'b> Compare<&'b [u8]> for &'a str { AsBStr::as_bstr(self).compare(t) } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: &'b [u8]) -> CompareResult { AsBStr::as_bstr(self).compare_no_case(t) } @@ -1769,6 +1781,7 @@ impl<'a, 'b> Compare> for &'a str { AsBStr::as_bstr(self).compare(t) } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: AsciiCaseless<&'b [u8]>) -> CompareResult { AsBStr::as_bstr(self).compare_no_case(t) } @@ -1785,6 +1798,7 @@ where } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: T) -> CompareResult { let bytes = (*self).as_bytes(); bytes.compare_no_case(t) @@ -1802,6 +1816,7 @@ where } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: T) -> CompareResult { let bytes = (*self).as_bytes(); bytes.compare_no_case(t) @@ -1818,6 +1833,7 @@ where } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, other: U) -> CompareResult { self.input.compare_no_case(other) } @@ -1833,6 +1849,7 @@ where } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, other: U) -> CompareResult { self.input.compare_no_case(other) } @@ -1848,6 +1865,7 @@ where } #[inline(always)] + #[allow(deprecated)] fn compare_no_case(&self, t: T) -> CompareResult { self.input.compare_no_case(t) } diff --git a/src/token/mod.rs b/src/token/mod.rs index 4459dfe8..e34181b2 100644 --- a/src/token/mod.rs +++ b/src/token/mod.rs @@ -218,6 +218,7 @@ where #[doc(alias = "literal")] #[doc(alias = "bytes")] #[doc(alias = "just")] +#[deprecated(since = "0.5.20", note = "Replaced with `tag(ascii::Caseless(_))`")] pub fn tag_no_case>( tag: T, ) -> impl Parser::Slice, Error> @@ -236,6 +237,7 @@ where }) } +#[allow(deprecated)] fn tag_no_case_, const PARTIAL: bool>( i: &mut I, t: T, diff --git a/src/token/tests.rs b/src/token/tests.rs index d9f36460..c39ba605 100644 --- a/src/token/tests.rs +++ b/src/token/tests.rs @@ -3,6 +3,7 @@ use super::*; #[cfg(feature = "std")] use proptest::prelude::*; +use crate::ascii::Caseless; use crate::binary::length_data; use crate::combinator::delimited; use crate::error::ErrMode; @@ -619,7 +620,7 @@ fn partial_length_bytes() { #[test] fn partial_case_insensitive() { fn test(i: Partial<&[u8]>) -> IResult, &[u8]> { - tag_no_case("ABcd").parse_peek(i) + tag(Caseless("ABcd")).parse_peek(i) } assert_eq!( test(Partial::new(&b"aBCdefgh"[..])), @@ -653,7 +654,7 @@ fn partial_case_insensitive() { ); fn test2(i: Partial<&str>) -> IResult, &str> { - tag_no_case("ABcd").parse_peek(i) + tag(Caseless("ABcd")).parse_peek(i) } assert_eq!( test2(Partial::new("aBCdefgh")), diff --git a/tests/testsuite/utf8.rs b/tests/testsuite/utf8.rs index 8e2ed387..0b6baf91 100644 --- a/tests/testsuite/utf8.rs +++ b/tests/testsuite/utf8.rs @@ -1,9 +1,10 @@ #[cfg(test)] mod test { + use winnow::ascii::Caseless; use winnow::Parser; use winnow::Partial; #[cfg(feature = "alloc")] - use winnow::{combinator::alt, combinator::repeat, token::tag_no_case}; + use winnow::{combinator::alt, combinator::repeat, token::tag}; use winnow::{ error::ErrMode, error::{ErrorKind, InputError}, @@ -74,7 +75,7 @@ mod test { #[test] fn tag_case_insensitive_str() { fn test(i: &str) -> IResult<&str, &str> { - tag_no_case("ABcd").parse_peek(i) + tag(Caseless("ABcd")).parse_peek(i) } assert_eq!(test("aBCdefgh"), Ok(("efgh", "aBCd"))); assert_eq!(test("abcdefgh"), Ok(("efgh", "abcd")));