[−][src]Struct liblet::automaton::Transition
A transition data structure to help abstracting automaton transitions
It is used in the automatons to define a transition between two states:
- from
- to
Transitions are labeled.
States are defined as collections of Symbols. To define a transition between two symbols, simply use singleton collections.
Implementations
impl<T> Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
pub fn new<IF, IT>(from: IF, label: Symbol, to: IT) -> Transition<T> where
IF: IntoIterator<Item = T>,
IT: IntoIterator<Item = T>,
[src]
IF: IntoIterator<Item = T>,
IT: IntoIterator<Item = T>,
Constructor for a new transition.
It takes the 3 fundamental details of a transition:
- the from collection
- the label of the transition
- the to collection
Examples
use liblet::automaton::Transition; use liblet::symbol::symbol; // here we define a transition of the form {A} --> "label" --> {B} let t = Transition::new(vec![symbol("A")], symbol("label"), vec![symbol("B")]);
pub fn from(&self) -> BTreeSet<T>
[src]
Return the set of symbols which defines the from state of this transition.
Examples
use liblet::automaton::Transition; use liblet::symbol::symbol; use std::collections::BTreeSet; use std::iter::FromIterator; let t = Transition::new(vec![symbol("A")], symbol("label"), vec![symbol("B")]); assert_eq!(t.from(), BTreeSet::from_iter(vec![symbol("A")]));
pub fn to(&self) -> BTreeSet<T>
[src]
Return the set of symbols which defines the to state of this transition.
Examples
use liblet::automaton::Transition; use liblet::symbol::symbol; use std::collections::BTreeSet; use std::iter::FromIterator; let t = Transition::new(vec![symbol("A")], symbol("label"), vec![symbol("B")]); assert_eq!(t.to(), BTreeSet::from_iter(vec![symbol("B")]));
pub fn label(&self) -> Symbol
[src]
Return the label of this transition, if present.
Examples
use liblet::automaton::Transition; use liblet::symbol::symbol; let t = Transition::new(vec![symbol("A")], symbol("label"), vec![symbol("B")]); assert_eq!(t.label(), symbol("label"));
impl Transition<Symbol>
[src]
pub fn from_string(
string: &str
) -> Result<Vec<Transition<Symbol>>, TransitionError>
[src]
string: &str
) -> Result<Vec<Transition<Symbol>>, TransitionError>
Construct a new transition from a string.
Errors
Can return a TokenizerError
Examples
use liblet::automaton::Transition; // here we define a transition of the form {A1,A2} --> "label" --> {B1,B2} let t = Transition::from_string("A1 A2 -> label -> B1 B2"); assert!(t.is_ok());
Trait Implementations
impl<T: Clone> Clone for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
fn clone(&self) -> Transition<T>
[src]
fn clone_from(&mut self, source: &Self)
1.0.0[src]
impl<T> Debug for Transition<T> where
T: Eq + Clone + Ord + Debug,
[src]
T: Eq + Clone + Ord + Debug,
impl<'de, T> Deserialize<'de> for Transition<T> where
T: Eq + Clone + Ord,
T: Deserialize<'de>,
[src]
T: Eq + Clone + Ord,
T: Deserialize<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
[src]
__D: Deserializer<'de>,
impl Display for Transition<Symbol>
[src]
impl<T: Eq> Eq for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
impl<T: Hash> Hash for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
fn hash<__H: Hasher>(&self, state: &mut __H)
[src]
fn hash_slice<H>(data: &[Self], state: &mut H) where
H: Hasher,
1.3.0[src]
H: Hasher,
impl<T: Ord> Ord for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
fn cmp(&self, other: &Transition<T>) -> Ordering
[src]
#[must_use]fn max(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn min(self, other: Self) -> Self
1.21.0[src]
#[must_use]fn clamp(self, min: Self, max: Self) -> Self
[src]
impl<T: PartialEq> PartialEq<Transition<T>> for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
fn eq(&self, other: &Transition<T>) -> bool
[src]
fn ne(&self, other: &Transition<T>) -> bool
[src]
impl<T: PartialOrd> PartialOrd<Transition<T>> for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
fn partial_cmp(&self, other: &Transition<T>) -> Option<Ordering>
[src]
fn lt(&self, other: &Transition<T>) -> bool
[src]
fn le(&self, other: &Transition<T>) -> bool
[src]
fn gt(&self, other: &Transition<T>) -> bool
[src]
fn ge(&self, other: &Transition<T>) -> bool
[src]
impl<T> Serialize for Transition<T> where
T: Eq + Clone + Ord,
T: Serialize,
[src]
T: Eq + Clone + Ord,
T: Serialize,
fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error> where
__S: Serializer,
[src]
__S: Serializer,
impl<T> StructuralEq for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
impl<T> StructuralPartialEq for Transition<T> where
T: Eq + Clone + Ord,
[src]
T: Eq + Clone + Ord,
impl<'_> TryFrom<&'_ str> for Transition<Symbol>
[src]
Auto Trait Implementations
impl<T> RefUnwindSafe for Transition<T> where
T: RefUnwindSafe,
T: RefUnwindSafe,
impl<T> Send for Transition<T> where
T: Send,
T: Send,
impl<T> Sync for Transition<T> where
T: Sync,
T: Sync,
impl<T> Unpin for Transition<T> where
T: Unpin,
T: Unpin,
impl<T> UnwindSafe for Transition<T> where
T: RefUnwindSafe + UnwindSafe,
T: RefUnwindSafe + UnwindSafe,
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> DeserializeOwned for T where
T: for<'de> Deserialize<'de>,
[src]
T: for<'de> Deserialize<'de>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> ToOwned for T where
T: Clone,
[src]
T: Clone,
type Owned = T
The resulting type after obtaining ownership.
fn to_owned(&self) -> T
[src]
fn clone_into(&self, target: &mut T)
[src]
impl<T> ToString for T where
T: Display + ?Sized,
[src]
T: Display + ?Sized,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,