NodeSet

Struct NodeSet 

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

A set of syntax parse rules of fixed size.

The set stores all entries in place, and the set object has a fixed size.

The maximum number of rules the object could store is NodeSet::LIMIT.

Most methods of this object are the const functions. Some of them take up to O(LIMIT) and O(LIMIT^2) time to perform.

The object is assumed to be constructed in a const context as a static value upfront to reduce the runtime overhead.

Implementations§

Source§

impl NodeSet

Source

pub const LIMIT: usize = 16usize

The maximum number of entries this set can address.

This number may be increased in future minor versions of Lady Deirdre.

Source

pub const fn empty() -> Self

Creates a node set without entries.

If you need just a static empty node set, use the predefined EMPTY_NODE_SET static.

Source

pub const fn new(rules: &[NodeRule]) -> Self

Constructs a node set from the slice of the node rules.

Panic

Panics if the rules parameter has more than the LIMIT number of unique node rules.

Panics if any value within the rules slice is a NON_RULE.

Source

pub const fn contains(&self, rule: NodeRule) -> bool

Returns true if the node set contains the specified node rule.

Source

pub const fn include(self, rule: NodeRule) -> Self

Consumes this NodeSet instance and returns a new node set that includes the rule node rule.

Panic

Panics if the rule argument is a NON_RULE.

Panics if the node set already has a LIMIT number of unique entries, and the rule argument is a new entry within this set.

Source

pub const fn include_all(self, rules: &[NodeRule]) -> Self

Consumes this NodeSet instance and returns a new node set that includes all node rules from the rules slice.

Panic

Panics if any rule number within the slice argument is a NON_RULE.

Panics if the total number if unique entries within this node set and the rules from the rules slice exceeds LIMIT.

Source

pub const fn exclude(self, rule: NodeRule) -> Self

Consumes this NodeSet instance and returns a new node set without the specified rule node rule.

Source

pub const fn exclude_all(self, rules: &[NodeRule]) -> Self

Consumes this NodeSet instance and returns a new node set without the entries specified in the rules node rule slice.

Source

pub const fn is_empty(&self) -> bool

Returns true if the NodeSet has no entries.

Source

pub const fn len(&self) -> usize

Returns the number of entries in this NodeSet instance.

Source

pub fn display<N: AbstractNode>(&self) -> impl Debug + Display + '_

Returns an object that displays all entries within this node set.

The N generic parameter specifies the syntax grammar of the programming language (see Node).

The underlying displaying algorithm uses the rule_name function to determine the rules’ display names.

Trait Implementations§

Source§

impl Clone for NodeSet

Source§

fn clone(&self) -> NodeSet

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl Debug for NodeSet

Source§

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

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

impl Default for NodeSet

Source§

fn default() -> NodeSet

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

impl FromIterator<u16> for NodeSet

Source§

fn from_iter<I: IntoIterator<Item = NodeRule>>(iter: I) -> Self

Creates a value from an iterator. Read more
Source§

impl<'set> IntoIterator for &'set NodeSet

Source§

type Item = u16

The type of the elements being iterated over.
Source§

type IntoIter = NodeSetIter<'set>

Which kind of iterator are we turning this into?
Source§

fn into_iter(self) -> Self::IntoIter

Creates an iterator from a value. Read more
Source§

impl PartialEq for NodeSet

Source§

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

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

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

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Copy for NodeSet

Source§

impl Eq for NodeSet

Source§

impl StructuralPartialEq for NodeSet

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