Skip to main content

ProgramBase

Struct ProgramBase 

Source
pub struct ProgramBase<R, Q, A, I = <R as RawRuleset<Q, A>>::Rule>
where Q: RawState, R: RawRuleset<Q, A, Rule = I> + ?Sized, I: Instruction<Q, A>,
{ /* private fields */ }
Expand description

The ProgramBase struct is used to define a generic program capable of being executed by a Turing machine or similar computational model. It consists of an optional initial state, a set of rules (or instructions) used to indicate how the machine should respond under different circumstances, and a marker to associate the generic parameters with the struct.

Implementations§

Source§

impl<R, I, Q, A> ProgramBase<R, Q, A, I>
where Q: RawState, R: RawRuleset<Q, A, Rule = I>, I: Instruction<Q, A>,

Source

pub const fn from_rules(rules: R) -> Self

initialize a new program from the given rule set

Source

pub const fn rules(&self) -> &R

returns a reference to the ruleset

Source

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

returns reference to the (optional) initial state

Source

pub fn set_initial_state(&mut self, initial_state: Q)

configure the initial state

Source

pub fn with_default_state<U>(self, initial_state: U) -> Self
where U: IntoState<Q>,

consumes the instance to create another with the given initial state

Source

pub fn get_head(&self, head: &Head<Q, A>) -> Option<&Tail<Q, A>>
where R: Ruleset<Q, A>, R::Rule: Instruction<Q, A, Head = Head<Q, A>, Tail = Tail<Q, A>>,

Source

pub fn find_tail(&self, state: State<&Q>, sym: &A) -> Option<&Tail<Q, A>>
where R: Ruleset<Q, A>, R::Rule: Instruction<Q, A, Head = Head<Q, A>, Tail = Tail<Q, A>>,

given a state and symbol, returns the corresponding tail if it exists within the ruleset

Source

pub fn len(&self) -> usize

returns the number of rules within the ruleset

Source

pub fn is_empty(&self) -> bool

returns true if the ruleset is considered empty (i.e. contains no rules), otherwise false.

Source§

impl<I, Q, A> ProgramBase<[I], Q, A, I>
where Q: RawState, I: Instruction<Q, A>,

Source

pub fn iter(&self) -> Iter<'_, I>

returns an iterator over the elements.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, I>

returns a mutable iterator over the elements.

Source§

impl<I, Q, A> ProgramBase<&[I], Q, A, I>
where Q: RawState, I: Instruction<Q, A>,

Source

pub fn iter(&self) -> Iter<'_, I>

returns an iterator over the elements.

Source§

impl<I, Q, A> ProgramBase<&mut [I], Q, A, I>
where Q: RawState, I: Instruction<Q, A>,

Source

pub fn iter(&self) -> Iter<'_, I>

returns an iterator over the elements.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, I>

returns a mutable iterator over the elements.

Source§

impl<const N: usize, I, Q, A> ProgramBase<[I; N], Q, A>
where Q: RawState, I: Instruction<Q, A>,

Source

pub fn iter(&self) -> Iter<'_, I>

returns an iterator over the elements.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, I>

returns a mutable iterator over the elements.

Source§

impl<I, Q, A> ProgramBase<Vec<I>, Q, A, I>
where Q: RawState, I: Instruction<Q, A>,

Source

pub fn iter(&self) -> Iter<'_, I>

returns an iterator over the elements.

Source

pub fn iter_mut(&mut self) -> IterMut<'_, I>

returns a mutable iterator over the elements.

Trait Implementations§

Source§

impl<R, Q, A: Clone, I> Clone for ProgramBase<R, Q, A, I>
where Q: RawState + Clone, R: RawRuleset<Q, A, Rule = I> + Clone + ?Sized, I: Instruction<Q, A> + Clone,

Source§

fn clone(&self) -> ProgramBase<R, Q, A, I>

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<R, I, Q, A> Debug for ProgramBase<R, Q, A, I>
where R: RawRuleset<Q, A, Rule = I> + Debug, Q: RawState + Debug, I: Instruction<Q, A> + Debug,

Source§

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

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

impl<R, Q, A: Default, I> Default for ProgramBase<R, Q, A, I>
where Q: RawState + Default, R: RawRuleset<Q, A, Rule = I> + Default + ?Sized, I: Instruction<Q, A> + Default,

Source§

fn default() -> ProgramBase<R, Q, A, I>

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

impl<R, I, Q, A> Display for ProgramBase<R, Q, A, I>
where R: RawRuleset<Q, A, Rule = I> + Debug, Q: RawState + Display, I: Instruction<Q, A> + Debug + Display,

Source§

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

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

impl<X, R, Q, A> Extend<X> for ProgramBase<R, Q, A, X>
where Q: RawState, X: Instruction<Q, A>, R: RawRuleset<Q, A, Rule = X> + Extend<X>,

Source§

fn extend<Iter>(&mut self, iter: Iter)
where Iter: IntoIterator<Item = X>,

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<X, R, Q, A> FromIterator<X> for ProgramBase<R, Q, A, X>
where Q: RawState, X: Instruction<Q, A>, R: RawRuleset<Q, A, Rule = X> + FromIterator<X>,

Source§

fn from_iter<Iter>(iter: Iter) -> Self
where Iter: IntoIterator<Item = X>,

Creates a value from an iterator. Read more
Source§

impl<R, Q, A: Hash, I> Hash for ProgramBase<R, Q, A, I>
where Q: RawState + Hash, R: RawRuleset<Q, A, Rule = I> + Hash + ?Sized, I: Instruction<Q, A> + Hash,

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<'a, X, I, R, Q, A> IntoIterator for &'a ProgramBase<R, Q, A, X>
where Q: RawState, X: 'a + Instruction<Q, A>, R: RawRuleset<Q, A, Rule = X>, I: Iterator<Item = &'a X>, for<'b> &'b R: IntoIterator<Item = &'b X, IntoIter = I>,

Source§

type Item = &'a X

The type of the elements being iterated over.
Source§

type IntoIter = I

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<I, X, R, Q, A> IntoIterator for ProgramBase<R, Q, A, X>
where I: Iterator<Item = X>, Q: RawState, X: Instruction<Q, A>, R: RawRuleset<Q, A, Rule = X> + IntoIterator<Item = X, IntoIter = I>,

Source§

type Item = <R as IntoIterator>::Item

The type of the elements being iterated over.
Source§

type IntoIter = <R as IntoIterator>::IntoIter

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<R, Q, A: Ord, I> Ord for ProgramBase<R, Q, A, I>
where Q: RawState + Ord, R: RawRuleset<Q, A, Rule = I> + Ord + ?Sized, I: Instruction<Q, A> + Ord,

Source§

fn cmp(&self, other: &ProgramBase<R, Q, A, I>) -> Ordering

This method returns an Ordering between self and other. Read more
1.21.0 · Source§

fn max(self, other: Self) -> Self
where Self: Sized,

Compares and returns the maximum of two values. Read more
1.21.0 · Source§

fn min(self, other: Self) -> Self
where Self: Sized,

Compares and returns the minimum of two values. Read more
1.50.0 · Source§

fn clamp(self, min: Self, max: Self) -> Self
where Self: Sized,

Restrict a value to a certain interval. Read more
Source§

impl<R, Q, A: PartialEq, I> PartialEq for ProgramBase<R, Q, A, I>
where Q: RawState + PartialEq, R: RawRuleset<Q, A, Rule = I> + PartialEq + ?Sized, I: Instruction<Q, A> + PartialEq,

Source§

fn eq(&self, other: &ProgramBase<R, Q, A, I>) -> 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<R, Q, A: PartialOrd, I> PartialOrd for ProgramBase<R, Q, A, I>
where Q: RawState + PartialOrd, R: RawRuleset<Q, A, Rule = I> + PartialOrd + ?Sized, I: Instruction<Q, A> + PartialOrd,

Source§

fn partial_cmp(&self, other: &ProgramBase<R, Q, A, I>) -> Option<Ordering>

This method returns an ordering between self and other values if one exists. Read more
1.0.0 · Source§

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

Tests less than (for self and other) and is used by the < operator. Read more
1.0.0 · Source§

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

Tests less than or equal to (for self and other) and is used by the <= operator. Read more
1.0.0 · Source§

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

Tests greater than (for self and other) and is used by the > operator. Read more
1.0.0 · Source§

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

Tests greater than or equal to (for self and other) and is used by the >= operator. Read more
Source§

impl<R, Q, A: Copy, I> Copy for ProgramBase<R, Q, A, I>
where Q: RawState + Copy, R: RawRuleset<Q, A, Rule = I> + Copy + ?Sized, I: Instruction<Q, A> + Copy,

Source§

impl<R, Q, A: Eq, I> Eq for ProgramBase<R, Q, A, I>
where Q: RawState + Eq, R: RawRuleset<Q, A, Rule = I> + Eq + ?Sized, I: Instruction<Q, A> + Eq,

Source§

impl<R, Q, A, I> StructuralPartialEq for ProgramBase<R, Q, A, I>
where Q: RawState, R: RawRuleset<Q, A, Rule = I> + ?Sized, I: Instruction<Q, A>,

Auto Trait Implementations§

§

impl<R, Q, A, I> Freeze for ProgramBase<R, Q, A, I>
where R: Freeze + ?Sized, Q: Freeze,

§

impl<R, Q, A, I> RefUnwindSafe for ProgramBase<R, Q, A, I>

§

impl<R, Q, A, I> Send for ProgramBase<R, Q, A, I>
where R: Send + ?Sized, Q: Send, I: Send, A: Send,

§

impl<R, Q, A, I> Sync for ProgramBase<R, Q, A, I>
where R: Sync + ?Sized, Q: Sync, I: Sync, A: Sync,

§

impl<R, Q, A, I> Unpin for ProgramBase<R, Q, A, I>
where R: Unpin + ?Sized, Q: Unpin, I: Unpin, A: Unpin,

§

impl<R, Q, A, I> UnwindSafe for ProgramBase<R, Q, A, I>

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<Q, A, T> IntoHead<Q, A> for T
where T: Into<Head<Q, A>>,

Source§

fn into_head(self) -> Head<Q, A>

Source§

impl<U, Q> IntoState<Q> for U
where Q: RawState, U: Into<State<Q>>,

Source§

fn __private__(&self) -> Seal

Source§

fn into_state(self) -> State<Q>

Source§

impl<S> Symbolic for S
where S: 'static + Clone + Default + Eq + Ord + Send + Sync + Debug + Display + Hash,

Source§

fn __private__(&self) -> Seal

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> ToString for T
where T: Display + ?Sized,

Source§

fn to_string(&self) -> String

Converts the given value to a String. 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<T> Wrapper<T> for T

Source§

type Cont<U> = U

Source§

fn get(&self) -> &T

returns a reference to the inner value
Source§

fn view(&self) -> <T as Wrapper<T>>::Cont<&T>

returns a view of the container containing an immutable reference to the inner value