turing_machine_rs/instruction/movement.rs
1use std::fmt::{Display, Error, Formatter};
2
3/// Move is a part of the [`crate::instruction::Tail`] and it's used for
4/// tape shift direction determining by [`crate::state::Configuration`].
5/// For any others structs direction value have no matter.
6///
7/// Turing Machine RS can works only with 1 dimension tape. That's why
8/// [`Move`] enumeration contains two directions variant:
9/// [`Move::Left`], [`Move::Right`].
10///
11/// Istead of using [`Option`], this enumeration provides one more
12/// variant - [`Move::None`].
13#[derive(Clone, Debug, Copy, PartialEq, Eq)]
14pub enum Move {
15 #[allow(missing_docs)]
16 Left,
17 #[allow(missing_docs)]
18 Right,
19 #[allow(missing_docs)]
20 None,
21}
22
23impl Display for Move {
24 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
25 match self {
26 Move::Left => write!(f, "<"),
27 Move::None => write!(f, "-"),
28 Move::Right => write!(f, ">"),
29 }
30 }
31}