Skip to main content

Command

Struct Command 

Source
pub struct Command { /* private fields */ }
Expand description

A control sequence with its greedily-attached argument groups.

Implementations§

Source§

impl Command

Source

pub fn control_word(&self) -> Option<ControlWord>

The leading CONTROL_WORD token, or None for a control symbol. The grammar bumps the control word as the command’s first token.

Source

pub fn name(&self) -> Option<String>

The control-word name (leading \ stripped), or None for a control symbol.

Source

pub fn control_word_range(&self) -> Option<TextRange>

The range of the leading CONTROL_WORD token (the \foo itself, backslash included), or None for a control symbol. Callers use this to underline just the control word rather than the whole node, which may carry greedily-attached argument groups.

Source

pub fn nth_group(&self, n: usize) -> Option<Group>

The n-th GROUP argument, if present. Filters GROUP only, so OPTIONAL arguments do not shift brace indexing (\cmd[o]{a}nth_group(0) is {a}).

Source

pub fn groups(&self) -> impl Iterator<Item = Group>

The GROUP argument nodes, in source order.

Source

pub fn optionals(&self) -> impl Iterator<Item = Optional>

The OPTIONAL argument nodes, in source order.

Source

pub fn nth_group_text(&self, n: usize) -> Option<String>

The literal text inside the n-th GROUP argument, braces dropped. Returns None when there is no n-th group or it holds non-token content (a nested command — not a flat literal). See Group::inner_text.

Source

pub fn nth_group_inner(&self, n: usize) -> Option<(TextRange, String)>

The byte range of the content inside the n-th GROUP argument together with that inner text — the location-aware counterpart to Command::nth_group_text. See Group::inner.

Source

pub fn first_group_range(&self) -> TextRange

The byte range of this command spanning its control word through the end of its first {…} group — e.g. \label{key} up to the closing brace of {key}. Deliberately not SyntaxNode::text_range, which the greedy parser may stretch over a second group it attached without knowing arity (\label{a}\n{…}; decision #8). Falls back to the full command range when the first group is absent.

Trait Implementations§

Source§

impl AstNode for Command

Source§

impl Clone for Command

Source§

fn clone(&self) -> Command

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for Command

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Eq for Command

Source§

impl Hash for Command

Source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · Source§

fn hash_slice<H>(data: &[Self], state: &mut H)
where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
Source§

impl PartialEq for Command

Source§

fn eq(&self, other: &Command) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl StructuralPartialEq for Command

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<Q, K> Equivalent<K> for Q
where Q: Eq + ?Sized, K: Borrow<Q> + ?Sized,

Source§

fn equivalent(&self, key: &K) -> bool

Checks if this value is equivalent to the given key. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.