Struct RuleMap

Source
pub struct RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,
{ /* private fields */ }

Implementations§

Source§

impl<Q, S> RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source

pub fn new() -> Self

Source

pub fn from_state(initial_state: State<Q>) -> Self

Source

pub fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (Head<Q, S>, Tail<Q, S>)>,

Source

pub fn from_rules<I>(iter: I) -> Self
where I: IntoIterator<Item = Rule<Q, S>>,

Source

pub fn with_initial_state(self, state: State<Q>) -> Self

configures the ruleset with the given initial state

Source

pub fn with_instructions( self, instructions: impl IntoIterator<Item = (Head<Q, S>, Tail<Q, S>)>, ) -> Self

Source

pub fn initial_state(&self) -> Option<State<&Q>>

returns an instance of State which owns a reference to the interval value.

Source

pub const fn rules(&self) -> &HashMap<Head<Q, S>, Tail<Q, S>>

returns an immutable reference to the set of rules.

Source

pub const fn rules_mut(&mut self) -> &mut HashMap<Head<Q, S>, Tail<Q, S>>

returns a mutable reference to the set of rules.

Source

pub fn clear(&mut self)

Clears the set of rules.

Source

pub fn rule(&mut self, head: Head<Q, S>) -> Entry<'_, Head<Q, S>, Tail<Q, S>>

returns an the entry for the given head within the set of rules.

Source

pub fn get_head<K>(&self, head: &K) -> Option<&Tail<Q, S>>
where K: Eq + Hash, Head<Q, S>: Borrow<K>,

returns an immutable reference to the tail of the rule for the given head; returns none if the head is not found.

Source

pub fn get_mut<K>(&mut self, head: &K) -> Option<&mut Tail<Q, S>>
where K: Eq + Hash, Head<Q, S>: Borrow<K>,

returns a mutable reference to the tail of the rule for the given head; returns none if the head is not found.

Source

pub fn get_ref<K>(&self, head: &K) -> Option<Tail<&Q, &S>>
where K: Eq + Hash, Head<Q, S>: Borrow<K>,

returns the tail of the rule for the given head; returns none if the head is not found within the set of rules.

Source

pub fn insert(&mut self, head: Head<Q, S>, tail: Tail<Q, S>)
where Q: RawState + Eq + Hash, S: Eq + Hash,

insert a new rule into the set of rules.

Source

pub fn insert_rule(&mut self, rule: Rule<Q, S>)
where Q: RawState + Eq + Hash, S: Eq + Hash,

insert a new rule into the set of rules.

Source

pub fn is_empty(&self) -> bool

returns true if the set of rules is empty.

Source

pub fn len(&self) -> usize

returns the number of rules in the set.

Source

pub fn or_insert( &mut self, head: Head<Q, S>, tail: Tail<Q, S>, ) -> &mut Tail<Q, S>

returns a mutable reference to the tail of the rule for the given head; inserts the tail if the head is not found.

Source

pub fn or_insert_with<F>(&mut self, head: Head<Q, S>, f: F) -> &mut Tail<Q, S>
where F: FnOnce() -> Tail<Q, S>,

returns a mutable reference to the tail of the rule for the given head; inserts the tail if the head is not found.

Source

pub fn or_insert_default(&mut self, head: Head<Q, S>) -> &mut Tail<Q, S>
where Q: Default, S: Default,

returns a mutable reference to the tail of the rule for the given head; inserts the default tail if the head is not found.

Source

pub fn remove(&mut self, head: &Head<Q, S>) -> Option<Tail<Q, S>>

Removes a rule from the set of rules.

Trait Implementations§

Source§

impl<Q, S> Clone for RuleMap<Q, S>
where Q: RawState + Eq + Hash + Clone, S: Eq + Hash + Clone,

Source§

fn clone(&self) -> RuleMap<Q, S>

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<Q, S> Debug for RuleMap<Q, S>
where Q: RawState + Eq + Hash + Debug, S: Eq + Hash + Debug,

Source§

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

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

impl<Q, S> Default for RuleMap<Q, S>
where Q: RawState + Eq + Hash + Default, S: Eq + Hash + Default,

Source§

fn default() -> RuleMap<Q, S>

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

impl<Q, S> Extend<(Head<Q, S>, Tail<Q, S>)> for RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = (Head<Q, S>, Tail<Q, S>)>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<Q, S> Extend<Rule<Q, S>> for RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

fn extend<I>(&mut self, iter: I)
where I: IntoIterator<Item = Rule<Q, S>>,

Extends a collection with the contents of an iterator. Read more
Source§

fn extend_one(&mut self, item: A)

🔬This is a nightly-only experimental API. (extend_one)
Extends a collection with exactly one element.
Source§

fn extend_reserve(&mut self, additional: usize)

🔬This is a nightly-only experimental API. (extend_one)
Reserves capacity in a collection for the given number of additional elements. Read more
Source§

impl<Q, S> FromIterator<(Head<Q, S>, Tail<Q, S>)> for RuleMap<Q, S>
where Q: RawState + Default + Eq + Hash, S: Eq + Hash,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = (Head<Q, S>, Tail<Q, S>)>,

Creates a value from an iterator. Read more
Source§

impl<Q, S> FromIterator<Rule<Q, S>> for RuleMap<Q, S>
where Q: RawState + Default + Eq + Hash, S: Eq + Hash,

Source§

fn from_iter<I>(iter: I) -> Self
where I: IntoIterator<Item = Rule<Q, S>>,

Creates a value from an iterator. Read more
Source§

impl<Q, S> Index<Head<Q, S>> for RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

type Output = Tail<Q, S>

The returned type after indexing.
Source§

fn index(&self, head: Head<Q, S>) -> &Self::Output

Performs the indexing (container[index]) operation. Read more
Source§

impl<'a, Q, S> IntoIterator for &'a RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

type Item = (&'a Head<Q, S>, &'a Tail<Q, S>)

The type of the elements being iterated over.
Source§

type IntoIter = Iter<'a, Head<Q, S>, Tail<Q, S>>

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<'a, Q, S> IntoIterator for &'a mut RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

type Item = (&'a Head<Q, S>, &'a mut Tail<Q, S>)

The type of the elements being iterated over.
Source§

type IntoIter = IterMut<'a, Head<Q, S>, Tail<Q, S>>

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<Q, S> IntoIterator for RuleMap<Q, S>
where Q: RawState + Eq + Hash, S: Eq + Hash,

Source§

type Item = (Head<Q, S>, Tail<Q, S>)

The type of the elements being iterated over.
Source§

type IntoIter = IntoIter<Head<Q, S>, Tail<Q, S>>

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<Q, S> Serialize for RuleMap<Q, S>
where Q: RawState + Eq + Hash + Serialize, S: Eq + Hash + Serialize,

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more

Auto Trait Implementations§

§

impl<Q, S> Freeze for RuleMap<Q, S>
where Q: Freeze,

§

impl<Q, S> RefUnwindSafe for RuleMap<Q, S>

§

impl<Q, S> Send for RuleMap<Q, S>
where S: Send,

§

impl<Q, S> Sync for RuleMap<Q, S>
where S: Sync,

§

impl<Q, S> Unpin for RuleMap<Q, S>
where Q: Unpin, S: Unpin,

§

impl<Q, S> UnwindSafe for RuleMap<Q, S>
where Q: UnwindSafe, S: UnwindSafe,

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<K, S> Identity<K> for S
where S: Borrow<K>, K: Identifier,

Source§

type Item = S

Source§

fn get(&self) -> &<S as Identity<K>>::Item

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more