Finite state machines in rust; bendns fork to add types.
Require State to have the Copy trait to remove possible interior mutability in INITIAL_STATE.
Yevhenii Babichenko 2019-04-29
parent 5c33ea7 · commit 0f184a8
-rw-r--r--rust_fsm/src/machine.rs2
-rw-r--r--rust_fsm_dsl/src/lib.rs2
2 files changed, 2 insertions, 2 deletions
diff --git a/rust_fsm/src/machine.rs b/rust_fsm/src/machine.rs
index a38f7eb..c5f3a32 100644
--- a/rust_fsm/src/machine.rs
+++ b/rust_fsm/src/machine.rs
@@ -6,7 +6,7 @@ pub trait StateMachine {
/// The input alphabet.
type Input;
/// The set of possible states.
- type State;
+ type State: Copy;
/// The output alphabet.
type Output;
/// The initial state of the machine.
diff --git a/rust_fsm_dsl/src/lib.rs b/rust_fsm_dsl/src/lib.rs
index 479e119..a16fb1b 100644
--- a/rust_fsm_dsl/src/lib.rs
+++ b/rust_fsm_dsl/src/lib.rs
@@ -142,7 +142,7 @@ pub fn state_machine(tokens: TokenStream) -> TokenStream {
let output = quote! {
struct #struct_name;
- #[derive(Debug, PartialEq)]
+ #[derive(Clone, Copy, Debug, PartialEq)]
enum #states_enum_name {
#(#states),*
}