Trait chumsky::text::Character

source ·
pub trait Character: Sealed + Copy + PartialEq {
    type Str: ?Sized + PartialEq;
    type Collection: Chain<Self> + FromIterator<Self> + AsRef<Self::Str> + 'static;

    // Required methods
    fn from_ascii(c: u8) -> Self;
    fn is_inline_whitespace(&self) -> bool;
    fn is_whitespace(&self) -> bool;
    fn digit_zero() -> Self;
    fn is_digit(&self, radix: u32) -> bool;
    fn to_char(&self) -> char;
}
Expand description

A trait implemented by textual character types (currently, u8 and char).

Avoid implementing this trait yourself if you can: it’s very likely to be expanded in future versions!

Required Associated Types§

source

type Str: ?Sized + PartialEq

The default unsized str-like type of a linear sequence of this character.

For char, this is str. For u8, this is [[u8]].

source

type Collection: Chain<Self> + FromIterator<Self> + AsRef<Self::Str> + 'static

The default type that this character collects into.

For char, this is String. For u8, this is Vec<u8>.

Required Methods§

source

fn from_ascii(c: u8) -> Self

Convert the given ASCII character to this character type.

source

fn is_inline_whitespace(&self) -> bool

Returns true if the character is canonically considered to be inline whitespace (i.e: not part of a newline).

source

fn is_whitespace(&self) -> bool

Returns true if the character is canonically considered to be whitespace.

source

fn digit_zero() -> Self

Return the ‘0’ digit of the character.

source

fn is_digit(&self, radix: u32) -> bool

Returns true if the character is canonically considered to be a numeric digit.

source

fn to_char(&self) -> char

Returns this character as a char.

Implementations on Foreign Types§

source§

impl Character for char

§

type Str = str

§

type Collection = String

source§

fn from_ascii(c: u8) -> Self

source§

fn is_inline_whitespace(&self) -> bool

source§

fn is_whitespace(&self) -> bool

source§

fn digit_zero() -> Self

source§

fn is_digit(&self, radix: u32) -> bool

source§

fn to_char(&self) -> char

source§

impl Character for u8

§

type Str = [u8]

§

type Collection = Vec<u8, Global>

source§

fn from_ascii(c: u8) -> Self

source§

fn is_inline_whitespace(&self) -> bool

source§

fn is_whitespace(&self) -> bool

source§

fn digit_zero() -> Self

source§

fn is_digit(&self, radix: u32) -> bool

source§

fn to_char(&self) -> char

Implementors§