Skip to main content

AltSpec

Struct AltSpec 

Source
pub struct AltSpec {
    pub m: Option<String>,
    /* private fields */
}
Expand description

One emitted alternate: the engine’s alt fields in the order they were written, plus the compiler-internal mark m, which never reaches the wire.

The fields are kept as an insertion-ordered map with JavaScript assignment semantics (set on an existing key updates it in place, on a new key appends it), because the canonical compiler builds each alternate as an object literal and the serialised text is byte-stable only when this port writes the keys in the same order at every site.

Fields§

§m: Option<String>

Implementations§

Source§

impl AltSpec

Source

pub fn new() -> AltSpec

Source

pub fn with_tag(tag: &str) -> AltSpec

{ g: tag }, the shape most alternates start from.

Source

pub fn set(&mut self, key: &str, value: impl Into<Value>) -> &mut AltSpec

Assign a field: an existing key keeps its position, a new one is appended.

Source

pub fn remove(&mut self, key: &str) -> Option<Value>

Source

pub fn get(&self, key: &str) -> Option<&Value>

Source

pub fn contains(&self, key: &str) -> bool

Source

pub fn assign_from(&mut self, other: &AltSpec) -> &mut AltSpec

Copy every field of other onto this alternate, in other’s order: the JavaScript spread { ...this, ...other }.

Source

pub fn s(&self) -> Option<&str>

The token sequence this alternate matches.

Source

pub fn p(&self) -> Option<&str>

The rule this alternate pushes.

Source

pub fn r(&self) -> Option<&str>

The rule this alternate replaces itself with.

Source

pub fn g(&self) -> Option<&str>

The group tag.

Source

pub fn b(&self) -> Option<u64>

How many matched tokens are pushed back.

Source

pub fn actions(&self) -> Vec<String>

The action refs, as a list: a scalar a is one, an array is each.

Source

pub fn set_actions(&mut self, actions: &[&str])

Assign the action refs: none removes a, one is a scalar on the wire, several are an array.

Source

pub fn append_action(&mut self, added: &str)

Append an action ref, producing the engine’s array-a form so the alt’s own action runs first.

Source

pub fn k(&self) -> Option<&Map<String, Value>>

The builtin config bag.

Source

pub fn k_mut(&mut self) -> Option<&mut Map<String, Value>>

Source

pub fn to_value(&self) -> Value

The alternate as the engine reads it, marks stripped.

Trait Implementations§

Source§

impl Clone for AltSpec

Source§

fn clone(&self) -> AltSpec

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 AltSpec

Source§

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

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

impl Default for AltSpec

Source§

fn default() -> AltSpec

Returns the “default value” for a type. Read more
Source§

impl PartialEq for AltSpec

Source§

fn eq(&self, other: &AltSpec) -> 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 AltSpec

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<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 = !

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

fn try_from(value: U) -> Result<T, !>

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.