use crate::MutationAutomatonBlueprint;
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
pub enum Either<A,B> {
Left(A),
Right(B)
}
impl<A,B, StateSort, Alphabet, ErrorType> MutationAutomatonBlueprint for Either<A,B>
where
A: MutationAutomatonBlueprint<StateSort = StateSort, Alphabet = Alphabet, ErrorType = ErrorType>,
B: MutationAutomatonBlueprint<StateSort = StateSort, Alphabet = Alphabet, ErrorType = ErrorType>,
StateSort: Clone,
Alphabet: PartialEq,
ErrorType: Default
{
type State = Either<A::State,B::State>;
type Alphabet = Alphabet;
type StateSort = StateSort;
type ErrorType = ErrorType;
fn initial_mutation_state(&self) -> Self::State {
match self {
Either::Left(x) => Either::Left(x.initial_mutation_state()),
Either::Right(y) => Either::Right(y.initial_mutation_state()),
}
}
fn mutation_state_sort_map(&self, state: &Self::State) -> Result<Self::StateSort,Self::ErrorType> {
match (self,state) {
(Either::Left(blueprint), Either::Left(state)) => blueprint.mutation_state_sort_map(state),
(Either::Left(_), Either::Right(_)) => Err(Default::default()),
(Either::Right(_), Either::Left(_)) => Err(Default::default()),
(Either::Right(blueprint), Either::Right(state)) => blueprint.mutation_state_sort_map(state),
}
}
fn mutation_transition_map(&self, state: &mut Self::State, character: &Self::Alphabet) -> Result<(), Self::ErrorType> {
match (self, state) {
(Either::Left(blueprint), Either::Left(state)) => blueprint.mutation_transition_map(state, character),
(Either::Left(_), Either::Right(_)) => Err(Default::default()),
(Either::Right(_), Either::Left(_)) => Err(Default::default()),
(Either::Right(blueprint), Either::Right(state)) => blueprint.mutation_transition_map(state, character),
}
}
}