Skip to content

Commit

Permalink
move usage towards AsChar method instead of functions under the chara…
Browse files Browse the repository at this point in the history
…cter module (#1597)

* feat: Add AsChar::is_space and AsChar::is_newline

* fix!: Remove character::is_* in favor of AsChar

This removes duplication and opens the way for changing complete vs
streaming parsers.

The problem is we still have something in `number` and `bits`

* Revert "fix!: Remove character::is_* in favor of AsChar"

This reverts commit 3897121.

* fix: Deprecate character::is_* functions

---------

Co-authored-by: Ed Page <eopage@gmail.com>
  • Loading branch information
Geal and epage committed May 5, 2024
1 parent c3291b1 commit d356bbe
Show file tree
Hide file tree
Showing 7 changed files with 109 additions and 136 deletions.
12 changes: 6 additions & 6 deletions src/bytes/complete.rs
Expand Up @@ -150,10 +150,10 @@ where
/// ```rust
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
/// use nom::bytes::complete::take_while;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while(is_alphabetic)(s)
/// take_while(AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down Expand Up @@ -181,10 +181,10 @@ where
/// ```rust
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
/// use nom::bytes::complete::take_while1;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while1(is_alphabetic)(s)
/// take_while1(AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down Expand Up @@ -212,10 +212,10 @@ where
/// ```rust
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
/// use nom::bytes::complete::take_while_m_n;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn short_alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while_m_n(3, 6, is_alphabetic)(s)
/// take_while_m_n(3, 6, AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(short_alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down
12 changes: 6 additions & 6 deletions src/bytes/streaming.rs
Expand Up @@ -152,10 +152,10 @@ where
/// ```rust
/// # use nom::{Err, error::ErrorKind, Needed, IResult};
/// use nom::bytes::streaming::take_while;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while(is_alphabetic)(s)
/// take_while(AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down Expand Up @@ -187,10 +187,10 @@ where
/// ```rust
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
/// use nom::bytes::streaming::take_while1;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while1(is_alphabetic)(s)
/// take_while1(AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down Expand Up @@ -220,10 +220,10 @@ where
/// ```rust
/// # use nom::{Err, error::{Error, ErrorKind}, Needed, IResult};
/// use nom::bytes::streaming::take_while_m_n;
/// use nom::character::is_alphabetic;
/// use nom::AsChar;
///
/// fn short_alpha(s: &[u8]) -> IResult<&[u8], &[u8]> {
/// take_while_m_n(3, 6, is_alphabetic)(s)
/// take_while_m_n(3, 6, AsChar::is_alpha)(s)
/// }
///
/// assert_eq!(short_alpha(b"latin123"), Ok((&b"123"[..], &b"latin"[..])));
Expand Down
15 changes: 7 additions & 8 deletions src/bytes/tests.rs
@@ -1,10 +1,10 @@
use crate::character::is_alphabetic;
use crate::character::streaming::{
alpha1 as alpha, alphanumeric1 as alphanumeric, bin_digit1 as bin_digit, digit1 as digit,
hex_digit1 as hex_digit, multispace1 as multispace, oct_digit1 as oct_digit, space1 as space,
};
use crate::error::ErrorKind;
use crate::internal::{Err, IResult, Needed};
use crate::AsChar;
use crate::Parser;
#[cfg(feature = "alloc")]
use crate::{
Expand Down Expand Up @@ -366,7 +366,7 @@ fn take_while() {
use crate::bytes::streaming::take_while;

fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_while(is_alphabetic)(i)
take_while(AsChar::is_alpha)(i)
}
let a = b"";
let b = b"abcd";
Expand All @@ -384,7 +384,7 @@ fn take_while1() {
use crate::bytes::streaming::take_while1;

fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_while1(is_alphabetic)(i)
take_while1(AsChar::is_alpha)(i)
}
let a = b"";
let b = b"abcd";
Expand All @@ -405,7 +405,7 @@ fn take_while_m_n() {
use crate::bytes::streaming::take_while_m_n;

fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_while_m_n(2, 4, is_alphabetic)(i)
take_while_m_n(2, 4, AsChar::is_alpha)(i)
}
let a = b"";
let b = b"a";
Expand All @@ -430,7 +430,7 @@ fn take_till() {
use crate::bytes::streaming::take_till;

fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_till(is_alphabetic)(i)
take_till(AsChar::is_alpha)(i)
}
let a = b"";
let b = b"abcd";
Expand All @@ -448,7 +448,7 @@ fn take_till1() {
use crate::bytes::streaming::take_till1;

fn f(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_till1(is_alphabetic)(i)
take_till1(AsChar::is_alpha)(i)
}
let a = b"";
let b = b"abcd";
Expand Down Expand Up @@ -557,11 +557,10 @@ fn take_while_m_n_utf8_full_match() {
#[cfg(feature = "std")]
fn recognize_take_while() {
use crate::bytes::streaming::take_while;
use crate::character::is_alphanumeric;
use crate::combinator::recognize;

fn x(i: &[u8]) -> IResult<&[u8], &[u8]> {
take_while(is_alphanumeric)(i)
take_while(AsChar::is_alphanum)(i)
}
fn y(i: &[u8]) -> IResult<&[u8], &[u8]> {
recognize(x).parse(i)
Expand Down
44 changes: 22 additions & 22 deletions src/character/complete.rs
Expand Up @@ -1096,18 +1096,18 @@ mod tests {
Err(Err::Error(error_position!(i, ErrorKind::HexDigit)))
);

assert!(crate::character::is_hex_digit(b'0'));
assert!(crate::character::is_hex_digit(b'9'));
assert!(crate::character::is_hex_digit(b'a'));
assert!(crate::character::is_hex_digit(b'f'));
assert!(crate::character::is_hex_digit(b'A'));
assert!(crate::character::is_hex_digit(b'F'));
assert!(!crate::character::is_hex_digit(b'g'));
assert!(!crate::character::is_hex_digit(b'G'));
assert!(!crate::character::is_hex_digit(b'/'));
assert!(!crate::character::is_hex_digit(b':'));
assert!(!crate::character::is_hex_digit(b'@'));
assert!(!crate::character::is_hex_digit(b'\x60'));
assert!(AsChar::is_hex_digit(b'0'));
assert!(AsChar::is_hex_digit(b'9'));
assert!(AsChar::is_hex_digit(b'a'));
assert!(AsChar::is_hex_digit(b'f'));
assert!(AsChar::is_hex_digit(b'A'));
assert!(AsChar::is_hex_digit(b'F'));
assert!(!AsChar::is_hex_digit(b'g'));
assert!(!AsChar::is_hex_digit(b'G'));
assert!(!AsChar::is_hex_digit(b'/'));
assert!(!AsChar::is_hex_digit(b':'));
assert!(!AsChar::is_hex_digit(b'@'));
assert!(!AsChar::is_hex_digit(b'\x60'));
}

#[test]
Expand All @@ -1121,16 +1121,16 @@ mod tests {
Err(Err::Error(error_position!(i, ErrorKind::OctDigit)))
);

assert!(crate::character::is_oct_digit(b'0'));
assert!(crate::character::is_oct_digit(b'7'));
assert!(!crate::character::is_oct_digit(b'8'));
assert!(!crate::character::is_oct_digit(b'9'));
assert!(!crate::character::is_oct_digit(b'a'));
assert!(!crate::character::is_oct_digit(b'A'));
assert!(!crate::character::is_oct_digit(b'/'));
assert!(!crate::character::is_oct_digit(b':'));
assert!(!crate::character::is_oct_digit(b'@'));
assert!(!crate::character::is_oct_digit(b'\x60'));
assert!(AsChar::is_oct_digit(b'0'));
assert!(AsChar::is_oct_digit(b'7'));
assert!(!AsChar::is_oct_digit(b'8'));
assert!(!AsChar::is_oct_digit(b'9'));
assert!(!AsChar::is_oct_digit(b'a'));
assert!(!AsChar::is_oct_digit(b'A'));
assert!(!AsChar::is_oct_digit(b'/'));
assert!(!AsChar::is_oct_digit(b':'));
assert!(!AsChar::is_oct_digit(b'@'));
assert!(!AsChar::is_oct_digit(b'\x60'));
}

#[test]
Expand Down
86 changes: 14 additions & 72 deletions src/character/mod.rs
Expand Up @@ -16,61 +16,30 @@ mod tests;
pub mod complete;
pub mod streaming;

/// Tests if byte is ASCII alphabetic: A-Z, a-z
///
/// # Example
///
/// ```
/// # use nom::character::is_alphabetic;
/// assert_eq!(is_alphabetic(b'9'), false);
/// assert_eq!(is_alphabetic(b'a'), true);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_alpha`")]
pub fn is_alphabetic(chr: u8) -> bool {
matches!(chr, 0x41..=0x5A | 0x61..=0x7A)
}

/// Tests if byte is ASCII digit: 0-9
///
/// # Example
///
/// ```
/// # use nom::character::is_digit;
/// assert_eq!(is_digit(b'a'), false);
/// assert_eq!(is_digit(b'9'), true);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_dec_digit`")]
pub fn is_digit(chr: u8) -> bool {
matches!(chr, 0x30..=0x39)
}

/// Tests if byte is ASCII hex digit: 0-9, A-F, a-f
///
/// # Example
///
/// ```
/// # use nom::character::is_hex_digit;
/// assert_eq!(is_hex_digit(b'a'), true);
/// assert_eq!(is_hex_digit(b'9'), true);
/// assert_eq!(is_hex_digit(b'A'), true);
/// assert_eq!(is_hex_digit(b'x'), false);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_hex_digit`")]
pub fn is_hex_digit(chr: u8) -> bool {
matches!(chr, 0x30..=0x39 | 0x41..=0x46 | 0x61..=0x66)
}

/// Tests if byte is ASCII octal digit: 0-7
///
/// # Example
///
/// ```
/// # use nom::character::is_oct_digit;
/// assert_eq!(is_oct_digit(b'a'), false);
/// assert_eq!(is_oct_digit(b'9'), false);
/// assert_eq!(is_oct_digit(b'6'), true);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_oct_digit`")]
pub fn is_oct_digit(chr: u8) -> bool {
matches!(chr, 0x30..=0x37)
}
Expand All @@ -91,50 +60,23 @@ pub fn is_bin_digit(chr: u8) -> bool {
matches!(chr, 0x30..=0x31)
}

/// Tests if byte is ASCII alphanumeric: A-Z, a-z, 0-9
///
/// # Example
///
/// ```
/// # use nom::character::is_alphanumeric;
/// assert_eq!(is_alphanumeric(b'-'), false);
/// assert_eq!(is_alphanumeric(b'a'), true);
/// assert_eq!(is_alphanumeric(b'9'), true);
/// assert_eq!(is_alphanumeric(b'A'), true);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_alphanum`")]
pub fn is_alphanumeric(chr: u8) -> bool {
is_alphabetic(chr) || is_digit(chr)

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test minimal rust version

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test minimal rust version

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features --features "alloc")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features --features "alloc")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features --features "alloc")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --no-default-features --features "alloc")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features --features "alloc")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features --features "alloc")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features --features "alloc")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly, --no-default-features --features "alloc")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (beta)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (nightly)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --features "std")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --features "std")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --features "std")

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (stable, --features "std")

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Bench

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Bench

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Bench

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Bench

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (1.65.0)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (1.65.0)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (1.65.0)

use of deprecated function `character::is_alphabetic`: Replaced with `AsChar::is_alpha`

Check warning on line 67 in src/character/mod.rs

View workflow job for this annotation

GitHub Actions / Test (1.65.0)

use of deprecated function `character::is_digit`: Replaced with `AsChar::is_dec_digit`
}

/// Tests if byte is ASCII space or tab
///
/// # Example
///
/// ```
/// # use nom::character::is_space;
/// assert_eq!(is_space(b'\n'), false);
/// assert_eq!(is_space(b'\r'), false);
/// assert_eq!(is_space(b' '), true);
/// assert_eq!(is_space(b'\t'), true);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_space`")]
pub fn is_space(chr: u8) -> bool {
chr == b' ' || chr == b'\t'
}

/// Tests if byte is ASCII newline: \n
///
/// # Example
///
/// ```
/// # use nom::character::is_newline;
/// assert_eq!(is_newline(b'\n'), true);
/// assert_eq!(is_newline(b'\r'), false);
/// assert_eq!(is_newline(b' '), false);
/// assert_eq!(is_newline(b'\t'), false);
/// ```
#[inline]
#[doc(hidden)]
#[deprecated(since = "8.0.0", note = "Replaced with `AsChar::is_newline`")]
pub fn is_newline(chr: u8) -> bool {
chr == b'\n'
}
Expand Down
44 changes: 22 additions & 22 deletions src/character/streaming.rs
Expand Up @@ -1060,18 +1060,18 @@ mod tests {
Err(Err::Error(error_position!(i, ErrorKind::HexDigit)))
);

assert!(crate::character::is_hex_digit(b'0'));
assert!(crate::character::is_hex_digit(b'9'));
assert!(crate::character::is_hex_digit(b'a'));
assert!(crate::character::is_hex_digit(b'f'));
assert!(crate::character::is_hex_digit(b'A'));
assert!(crate::character::is_hex_digit(b'F'));
assert!(!crate::character::is_hex_digit(b'g'));
assert!(!crate::character::is_hex_digit(b'G'));
assert!(!crate::character::is_hex_digit(b'/'));
assert!(!crate::character::is_hex_digit(b':'));
assert!(!crate::character::is_hex_digit(b'@'));
assert!(!crate::character::is_hex_digit(b'\x60'));
assert!(AsChar::is_hex_digit(b'0'));
assert!(AsChar::is_hex_digit(b'9'));
assert!(AsChar::is_hex_digit(b'a'));
assert!(AsChar::is_hex_digit(b'f'));
assert!(AsChar::is_hex_digit(b'A'));
assert!(AsChar::is_hex_digit(b'F'));
assert!(!AsChar::is_hex_digit(b'g'));
assert!(!AsChar::is_hex_digit(b'G'));
assert!(!AsChar::is_hex_digit(b'/'));
assert!(!AsChar::is_hex_digit(b':'));
assert!(!AsChar::is_hex_digit(b'@'));
assert!(!AsChar::is_hex_digit(b'\x60'));
}

#[test]
Expand All @@ -1085,16 +1085,16 @@ mod tests {
Err(Err::Error(error_position!(i, ErrorKind::OctDigit)))
);

assert!(crate::character::is_oct_digit(b'0'));
assert!(crate::character::is_oct_digit(b'7'));
assert!(!crate::character::is_oct_digit(b'8'));
assert!(!crate::character::is_oct_digit(b'9'));
assert!(!crate::character::is_oct_digit(b'a'));
assert!(!crate::character::is_oct_digit(b'A'));
assert!(!crate::character::is_oct_digit(b'/'));
assert!(!crate::character::is_oct_digit(b':'));
assert!(!crate::character::is_oct_digit(b'@'));
assert!(!crate::character::is_oct_digit(b'\x60'));
assert!(AsChar::is_oct_digit(b'0'));
assert!(AsChar::is_oct_digit(b'7'));
assert!(!AsChar::is_oct_digit(b'8'));
assert!(!AsChar::is_oct_digit(b'9'));
assert!(!AsChar::is_oct_digit(b'a'));
assert!(!AsChar::is_oct_digit(b'A'));
assert!(!AsChar::is_oct_digit(b'/'));
assert!(!AsChar::is_oct_digit(b':'));
assert!(!AsChar::is_oct_digit(b'@'));
assert!(!AsChar::is_oct_digit(b'\x60'));
}

#[test]
Expand Down

0 comments on commit d356bbe

Please sign in to comment.