Trait CharType

Source
pub trait CharType:
    Copy
    + PartialEq
    + Eq
    + Hash
    + Display
    + Debug
    + 'static
    + From<u8>
    + Default {
    type Allchars<A: Default>: AllCharsTrait<Self, A>;

    const MAX: Self;
Show 19 methods // Required methods fn from_u8_iter(iter: &mut IntoIter<u8>) -> Option<Self>; fn from_str(s: &str) -> TeXStr<Self>; fn is_eol(self) -> Option<bool>; fn is_eol_pair(self, next: Self) -> bool; fn par_token() -> TeXStr<Self>; fn relax_token() -> TeXStr<Self>; fn empty_str() -> TeXStr<Self>; fn starting_catcode_scheme() -> CategoryCodeScheme<Self>; fn newline() -> Self; fn carriage_return() -> Self; fn backslash() -> Self; fn zeros() -> Self::Allchars<Self>; fn ident() -> Self::Allchars<Self>; fn rep_field<A: Clone + Default>(a: A) -> Self::Allchars<A>; fn char_str(&self) -> String; fn as_bytes(&self) -> Vec<u8> ; fn from_i64(i: i64) -> Option<Self>; fn to_usize(self) -> usize; // Provided method fn display_str(str: &TeXStr<Self>, f: &mut Formatter<'_>) -> Result { ... }
}
Expand description

Plain TeX parses source files as a sequence of u8s, but other engines might use bigger types, e.g. XeTeX. This trait allows us to abstract over the character type, by providing the relevant data needed to treat them (essentially) like u8s.

Required Associated Constants§

Source

const MAX: Self

The maximum value of the character type. For u8, this is 255.

Required Associated Types§

Source

type Allchars<A: Default>: AllCharsTrait<Self, A>

The type of the array/vec/whatever of all possible characters. For u8, this is [A;256].

Required Methods§

Source

fn from_u8_iter(iter: &mut IntoIter<u8>) -> Option<Self>

Parses a character from a byte iterator. For u8, this is just iter.next().

Source

fn from_str(s: &str) -> TeXStr<Self>

Convert a &str into a TeXStr<Self>.

Source

fn is_eol(self) -> Option<bool>

Whether the character is an end-of-line character.

Should return:

  • Some(true): is end of line (e.g. \n).
  • Some(false): is not end of line.
  • None: might be, depending on the next character - e.g. \r, in which case the next character should be checked to be \n.
Source

fn is_eol_pair(self, next: Self) -> bool

Should return:

  • true: if the pair (self,next) represents an end of line (e.g. \r\n).
  • false: if not; in which case self itself is considered to be an end of line (e.g. \r).
Source

fn par_token() -> TeXStr<Self>

The string “par” as a TeXStr<Self>.

Source

fn relax_token() -> TeXStr<Self>

The string “relax” as a TeXStr<Self>.

Source

fn empty_str() -> TeXStr<Self>

The empty string as a TeXStr<Self>.

Source

fn starting_catcode_scheme() -> CategoryCodeScheme<Self>

The starting category code scheme for this character type, see STARTING_SCHEME_U8.

Source

fn newline() -> Self

Source

fn carriage_return() -> Self

Source

fn backslash() -> Self

Source

fn zeros() -> Self::Allchars<Self>

Source

fn ident() -> Self::Allchars<Self>

Source

fn rep_field<A: Clone + Default>(a: A) -> Self::Allchars<A>

Source

fn char_str(&self) -> String

Source

fn as_bytes(&self) -> Vec<u8>

Source

fn from_i64(i: i64) -> Option<Self>

Source

fn to_usize(self) -> usize

Provided Methods§

Source

fn display_str(str: &TeXStr<Self>, f: &mut Formatter<'_>) -> Result

How to display a TeXStr<Self>.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.

Implementations on Foreign Types§

Source§

impl CharType for char

Source§

const MAX: Self = 'ÿ'

Source§

type Allchars<A: Default> = AllUnicodeChars<A>

Source§

fn from_i64(i: i64) -> Option<Self>

Source§

fn to_usize(self) -> usize

Source§

fn from_str(s: &str) -> TeXStr<Self>

Source§

fn display_str(str: &TeXStr<Self>, f: &mut Formatter<'_>) -> Result

Source§

fn backslash() -> Self

Source§

fn carriage_return() -> Self

Source§

fn newline() -> Self

Source§

fn char_str(&self) -> String

Source§

fn is_eol(self) -> Option<bool>

Source§

fn is_eol_pair(self, next: Self) -> bool

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn ident() -> Self::Allchars<Self>

Source§

fn empty_str() -> TeXStr<Self>

Source§

fn par_token() -> TeXStr<Self>

Source§

fn relax_token() -> TeXStr<Self>

Source§

fn starting_catcode_scheme() -> CategoryCodeScheme<Self>

Source§

fn from_u8_iter(iter: &mut IntoIter<u8>) -> Option<Self>

Source§

fn rep_field<A: Clone + Default>(a: A) -> Self::Allchars<A>

Source§

fn zeros() -> Self::Allchars<Self>

Source§

impl CharType for u8

Source§

const MAX: Self = 255u8

Source§

type Allchars<A: Default> = [A; 256]

Source§

fn from_u8_iter(iter: &mut IntoIter<u8>) -> Option<Self>

Source§

fn newline() -> Self

Source§

fn carriage_return() -> Self

Source§

fn backslash() -> Self

Source§

fn is_eol(self) -> Option<bool>

Source§

fn from_str(s: &str) -> TeXStr<Self>

Source§

fn is_eol_pair(self, next: Self) -> bool

Source§

fn par_token() -> TeXStr<Self>

Source§

fn relax_token() -> TeXStr<Self>

Source§

fn empty_str() -> TeXStr<Self>

Source§

fn starting_catcode_scheme() -> CategoryCodeScheme<Self>

Source§

fn as_bytes(&self) -> Vec<u8>

Source§

fn char_str(&self) -> String

Source§

fn zeros() -> Self::Allchars<Self>

Source§

fn ident() -> Self::Allchars<Self>

Source§

fn rep_field<A: Clone + Default>(a: A) -> Self::Allchars<A>

Source§

fn from_i64(i: i64) -> Option<Self>

Source§

fn to_usize(self) -> usize

Implementors§