turing_machine_rs/instruction/
state.rs1use std::fmt::{Display, Error, Formatter};
2use std::ops::{Add, AddAssign};
3
4#[derive(Clone, Debug, Copy, PartialEq, Eq, PartialOrd, Ord)]
12pub struct State(pub usize);
13
14impl Display for State {
15 fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), Error> {
16 write!(f, "{}", self.0)
17 }
18}
19
20impl Add for State {
21 type Output = State;
22
23 fn add(self, rhs: Self) -> Self {
24 State(self.0 + rhs.0)
25 }
26}
27
28impl AddAssign for State {
29 fn add_assign(&mut self, other: Self) {
30 self.0 += other.0;
31 }
32}