pub struct CompactToken(/* private fields */);Expand description
A compact representation of a Token with Char==u8 and CS==InternedCSName
as a single u32 (similar to the way plain TeX does it) – i.e. it is small and Copy, which yields a significant
performance improvement in the most performance critical parts of the code.
Values up to 0x8000_0000 are interpreted as interned control sequences, and the rest as character tokens. The downside
is that we need an interning table for control sequences, that needs passing around whenever we want to
make a Token from a control sequence name or display a CompactToken to the user in a comprehensible way.
(Also, we can only have 2³¹ control sequences in total, but that limit is ridiculously large.)
Trait Implementations§
Source§impl Clone for CompactToken
impl Clone for CompactToken
Source§fn clone(&self) -> CompactToken
fn clone(&self) -> CompactToken
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for CompactToken
impl Debug for CompactToken
Source§impl PartialEq for CompactToken
impl PartialEq for CompactToken
Source§impl Token for CompactToken
impl Token for CompactToken
Source§type CS = (NonZero<u32>, PhantomData<u8>)
type CS = (NonZero<u32>, PhantomData<u8>)
The
CSName type used for control sequence names (e.g. Rc<str> or something interned).Source§fn to_enum(&self) -> StandardToken<u8, InternedCSName<u8>>
fn to_enum(&self) -> StandardToken<u8, InternedCSName<u8>>
Converts to the canonical enum representation of a token, i.e.
StandardToken.Source§fn from_char_cat(c: u8, cat: CommandCode) -> Self
fn from_char_cat(c: u8, cat: CommandCode) -> Self
Create a new character token with given
CommandCode (i.e.
conceptually the CategoryCode).Source§fn primitive(id: PrimitiveIdentifier) -> Self
fn primitive(id: PrimitiveIdentifier) -> Self
fn is_primitive(&self) -> Option<PrimitiveIdentifier>
Source§fn argument_marker(i: u8) -> Self
fn argument_marker(i: u8) -> Self
Create a new argument marker token.
i needs to be in the range 0..=8.Source§fn command_code(&self) -> CommandCode
fn command_code(&self) -> CommandCode
The
CommandCode (i.e. conceptually the CategoryCode) of this token.Source§fn char_value(&self) -> Option<Self::Char>
fn char_value(&self) -> Option<Self::Char>
The
Character value of this token, if it is a character token.Source§fn is_cs_or_active(&self) -> bool
fn is_cs_or_active(&self) -> bool
Check if this token is a control sequence or an active character
Source§fn is_cs(&self, name: &Self::CS) -> bool
fn is_cs(&self, name: &Self::CS) -> bool
Check if this token is a control sequence with the given name.
Source§fn is_argument_marker(&self) -> Option<u8>
fn is_argument_marker(&self) -> Option<u8>
Check if this token is a argument token, and if so, return its number (in the range
0..=8).Source§fn display_fmt<W: Write>(
&self,
int: &<Self::CS as CSName<Self::Char>>::Handler,
cc: &CategoryCodeScheme<Self::Char>,
escapechar: Option<Self::Char>,
f: &mut W,
) -> Result
fn display_fmt<W: Write>( &self, int: &<Self::CS as CSName<Self::Char>>::Handler, cc: &CategoryCodeScheme<Self::Char>, escapechar: Option<Self::Char>, f: &mut W, ) -> Result
Display this token to a writer, using the given
CSHandler (in case it is a control sequence).
In that case, we also need the current \escapechar to optionally insert it in front of the control sequence
name, and the current CategoryCodeScheme to determine whether or not to insert a space afterwards - which
we do unless the control sequence name is a single character with any CommandCode other than
Letter.impl Copy for CompactToken
impl Eq for CompactToken
Auto Trait Implementations§
impl Freeze for CompactToken
impl RefUnwindSafe for CompactToken
impl Send for CompactToken
impl Sync for CompactToken
impl Unpin for CompactToken
impl UnsafeUnpin for CompactToken
impl UnwindSafe for CompactToken
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Checks if this value is equivalent to the given key. Read more
§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more