Finite state machines in rust; bendns fork to add types.
-rw-r--r--CHANGELOG.md2
-rw-r--r--README.md6
-rw-r--r--rust-fsm/src/lib.rs6
3 files changed, 8 insertions, 6 deletions
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 2855aa8..fe1db49 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,8 @@ The format is based on [Keep a Changelog][keepachangelog], and this project
adheres to [Semantic Versioning][semver].
## [Unreleased]
+### Changed
+* Use pattern pattern matching in examples.
## [0.6.0] - 2021-08-24
### Changed
diff --git a/README.md b/README.md
index fa81331..97f2990 100644
--- a/README.md
+++ b/README.md
@@ -88,13 +88,13 @@ let mut machine: StateMachine<CircuitBreaker> = StateMachine::new();
let _ = machine.consume(&CircuitBreakerInput::Successful);
// Consume the `Unsuccesful` input. The machine is moved to the `Open`
// state. The output is `SetupTimer`.
-let output = machine.consume(&CircuitBreakerInput::Unsuccesful).unwrap();
+let output = machine.consume(&CircuitBreakerInput::Unsuccessful).unwrap();
// Check the output
-if output == Some(CircuitBreakerOutput::SetupTimer) {
+if let Some(CircuitBreakerOutput::SetupTimer) = output {
// Set up the timer...
}
// Check the state
-if machine.state() == &CircuitBreakerState::Open {
+if let CircuitBreakerState::Open = machine.state() {
// Do something...
}
```
diff --git a/rust-fsm/src/lib.rs b/rust-fsm/src/lib.rs
index 7d37656..84c82cc 100644
--- a/rust-fsm/src/lib.rs
+++ b/rust-fsm/src/lib.rs
@@ -85,13 +85,13 @@
//! let _ = machine.consume(&CircuitBreakerInput::Successful);
//! // Consume the `Unsuccesful` input. The machine is moved to the `Open`
//! // state. The output is `SetupTimer`.
-//! let output = machine.consume(&CircuitBreakerInput::Unsuccesful).unwrap();
+//! let output = machine.consume(&CircuitBreakerInput::Unsuccessful).unwrap();
//! // Check the output
-//! if output == Some(CircuitBreakerOutput::SetupTimer) {
+//! if let Some(CircuitBreakerOutput::SetupTimer) = output {
//! // Set up the timer...
//! }
//! // Check the state
-//! if machine.state() == &CircuitBreakerState::Open {
+//! if let CircuitBreakerState::Open = machine.state() {
//! // Do something...
//! }
//! ```