Struct Head

Source
#[repr(C)]
pub struct Head<Q, S> { pub state: State<Q>, pub symbol: S, }
Expand description

The Head is formally defined to be a 2-tuple consisting of a state / symbol pair.

Fields§

§state: State<Q>§symbol: S

Implementations§

Source§

impl<Q, S> Head<Q, S>
where Q: RawState,

Source

pub const fn new(state: State<Q>, symbol: S) -> Self

Source

pub fn from_state(state: State<Q>) -> Self
where S: Default,

Create a new instance of the Head using the given state and default symbol.

Source

pub fn from_symbol(symbol: S) -> Self
where Q: Default,

Create a new instance of the Head using the given symbol and default state.

Source

pub fn from_tuple((state, symbol): (State<Q>, S)) -> Self

Create a new instance from a 2-tuple: (state, symbol)

Source

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

Updates the current state and returns a new head

Source

pub fn with_symbol(self, symbol: S) -> Self

Updates the current symbol and returns a new head

Source

pub const fn state(&self) -> &State<Q>

Returns a reference to the current state

Source

pub const fn state_mut(&mut self) -> &mut State<Q>

Returns a mutable reference to the current State

Source

pub const fn symbol(&self) -> &S

Returns a reference to the current symbol

Source

pub const fn symbol_mut(&mut self) -> &mut S

Returns a mutable reference to the current symbol

Source

pub fn as_tuple(&self) -> (&State<Q>, &S)

Returns a reference to the current state and symbol returing a 2-tuple

Source

pub fn into_tuple(self) -> (State<Q>, S)

Consumes the head and returns the current state and symbol as a 2-tuple

Source

pub fn as_mut_tuple(&mut self) -> (&mut State<Q>, &mut S)

Returns a mutable reference to the current state and symbol as a 2-tuple

Source

pub fn set_state(&mut self, State: State<Q>) -> &mut Self

Updates the current state

Source

pub fn set_symbol(&mut self, symbol: S) -> &mut Self

Updates the current symbol

Source

pub fn replace(&mut self, state: State<Q>, symbol: S) -> Self

Replaces the current state and symbol with the given state and symbol; returns the previous instance of the head.

Source

pub const fn replace_state(&mut self, state: State<Q>) -> State<Q>

replace the current state with the given state, returning the previous state

Source

pub const fn replace_symbol(&mut self, symbol: S) -> S

replace the current symbol with the given symbol, returning the previous symbol

Source

pub const fn swap(&mut self, other: &mut Self)

swap the current state and symbol with those of the given head

Source

pub fn update(&mut self, state: Option<State<Q>>, symbol: Option<S>)

Updates the current State and symbol

Source

pub const fn view(&self) -> Head<&Q, &S>

returns a new head with immutable references to the current state and symbol

Source

pub fn view_mut(&mut self) -> Head<&mut Q, &mut S>

returns a new head with mutable references to the current state and symbol

Source

pub fn read<T>(self, tape: &[T]) -> Option<&S::Output>
where S: SliceIndex<[T]>,

tries reading the given tape using the head as its coordinates.

Source

pub fn to_ref(&self) -> Head<&Q, &S>

👎Deprecated since 0.0.7: use view instead, as it is more idiomatic and clearer.
Source

pub fn to_mut(&mut self) -> Head<&mut Q, &mut S>

👎Deprecated since 0.0.7: use view_mut instead, as it is more idiomatic and clearer.
Source§

impl<'a, Q, S> Head<&'a Q, &'a S>
where Q: RawState,

Source

pub fn cloned(&self) -> Head<Q, S>
where Q: Clone, S: Clone,

returns a new Head with cloned elements

Source

pub fn copied(&self) -> Head<Q, S>
where Q: Copy, S: Copy,

returns a new Head with copied elements

Source§

impl<'a, Q, S> Head<&'a mut Q, &'a mut S>
where Q: RawState,

Source

pub fn cloned(&self) -> Head<Q, S>
where Q: Clone, S: Clone,

returns a new Head with cloned elements

Source

pub fn copied(&self) -> Head<Q, S>
where Q: Copy, S: Copy,

returns a new Head with copied elements

Source§

impl<Q> Head<Q, usize>
where Q: RawState,

Source

pub fn shift(self, direction: Direction) -> Self

Source

pub fn shift_inplace(&mut self, direction: Direction)

Trait Implementations§

Source§

impl<Q, S> AsMut<Head<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn as_mut(&mut self) -> &mut Head<Q, S>

Converts this type into a mutable reference of the (usually inferred) input type.
Source§

impl<Q, S> AsRef<Head<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn as_ref(&self) -> &Head<Q, S>

Converts this type into a shared reference of the (usually inferred) input type.
Source§

impl<Q, S> Borrow<Head<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn borrow(&self) -> &Head<Q, S>

Immutably borrows from an owned value. Read more
Source§

impl<Q, S> BorrowMut<Head<Q, S>> for Rule<Q, S>
where Q: RawState,

Source§

fn borrow_mut(&mut self) -> &mut Head<Q, S>

Mutably borrows from an owned value. Read more
Source§

impl<Q: Clone, S: Clone> Clone for Head<Q, S>

Source§

fn clone(&self) -> Head<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 Head<Q, S>
where Q: RawState, S: Debug,

Source§

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

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

impl<Q: Default, S: Default> Default for Head<Q, S>

Source§

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

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

impl<'de, Q, S> Deserialize<'de> for Head<Q, S>
where Q: Deserialize<'de>, S: Deserialize<'de>,

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl<Q, S> Display for Head<Q, S>
where Q: RawState, S: Display,

Source§

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

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

impl<Q, S> From<(Q, S)> for Head<Q, S>
where Q: RawState,

Source§

fn from((state, symbol): (Q, S)) -> Self

Converts to this type from the input type.
Source§

impl<Q, S> From<(State<Q>, S)> for Head<Q, S>
where Q: RawState,

Source§

fn from((state, symbol): (State<Q>, S)) -> Self

Converts to this type from the input type.
Source§

impl<Q, S> From<Head<Q, S>> for (State<Q>, S)
where Q: RawState,

Source§

fn from(head: Head<Q, S>) -> Self

Converts to this type from the input type.
Source§

impl<Q: Hash, S: Hash> Hash for Head<Q, S>

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<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<Q, S> Index<Head<Q, S>> for RuleSet<Q, S>
where Q: RawState + PartialEq, S: PartialEq,

Source§

type Output = Tail<Q, S>

The returned type after indexing.
Source§

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

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

impl<Q: Ord, S: Ord> Ord for Head<Q, S>

Source§

fn cmp(&self, other: &Head<Q, S>) -> 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<Q, S> PartialEq<(Q, S)> for Head<Q, S>

Source§

fn eq(&self, (state, symbol): &(Q, S)) -> 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<Q, S> PartialEq<(State<Q>, S)> for Head<Q, S>
where Q: RawState + PartialEq, S: PartialEq,

Source§

fn eq(&self, (state, symbol): &(State<Q>, S)) -> 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<Q, S> PartialEq<Head<Q, S>> for (State<Q>, S)
where Q: RawState + PartialEq, S: PartialEq,

Source§

fn eq(&self, head: &Head<Q, S>) -> 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<Q, S> PartialEq<Head<Q, S>> for Rule<Q, S>
where Q: RawState + PartialEq, S: PartialEq,

Source§

fn eq(&self, other: &Head<Q, S>) -> 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<Q, S> PartialEq<Head<Q, S>> for State<&Q>
where Q: RawState + PartialEq,

Source§

fn eq(&self, head: &Head<Q, S>) -> 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<Q, S> PartialEq<Head<Q, S>> for State<Q>
where Q: RawState + PartialEq,

Source§

fn eq(&self, head: &Head<Q, S>) -> 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<'a, Q, S> PartialEq<State<&'a Q>> for Head<Q, S>
where Q: RawState + PartialEq,

Source§

fn eq(&self, state: &State<&'a Q>) -> 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<Q, S> PartialEq<State<Q>> for Head<Q, S>
where Q: RawState + PartialEq,

Source§

fn eq(&self, state: &State<Q>) -> 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<Q: PartialEq, S: PartialEq> PartialEq for Head<Q, S>

Source§

fn eq(&self, other: &Head<Q, S>) -> 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<Q: PartialOrd, S: PartialOrd> PartialOrd for Head<Q, S>

Source§

fn partial_cmp(&self, other: &Head<Q, S>) -> 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<Q, S> Scope<Q, S> for Head<Q, S>
where Q: RawState,

Source§

impl<Q, S> Serialize for Head<Q, S>
where Q: Serialize, S: 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
Source§

impl<Q: Copy, S: Copy> Copy for Head<Q, S>

Source§

impl<Q: Eq, S: Eq> Eq for Head<Q, S>

Source§

impl<Q, S> StructuralPartialEq for Head<Q, S>

Auto Trait Implementations§

§

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

§

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

§

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

§

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

§

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

§

impl<Q, S> UnwindSafe for Head<Q, S>
where S: UnwindSafe, Q: 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> 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<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
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

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