Finite state machines in rust; bendns fork to add types.
Diffstat (limited to 'src/lib.rs')
-rw-r--r--src/lib.rs8
1 files changed, 7 insertions, 1 deletions
diff --git a/src/lib.rs b/src/lib.rs
index 991df4a..16b189a 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -149,8 +149,14 @@ where
/// Create a new instance of this wrapper which encapsulates the initial
/// state.
pub fn new() -> Self {
+ Self::from_state(T::INITIAL_STATE)
+ }
+
+ /// Create a new instance of this wrapper which encapsulates the given
+ /// state.
+ pub fn from_state(state: T::State) -> Self {
Self {
- state: T::INITIAL_STATE,
+ state
}
}