Skip to content

Commit

Permalink
Merge v0.2.2 into master
Browse files Browse the repository at this point in the history
  • Loading branch information
andrewtc committed Feb 12, 2019
1 parent f498b8c commit a437c5b
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
5 changes: 4 additions & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "mode"
version = "0.2.1"
version = "0.2.2"
authors = ["Andrew Thomas Christensen <[email protected]>"]
edition = "2018"

Expand All @@ -16,4 +16,7 @@ categories = ["rust-patterns", "simulation", "data-structures"]

license = "Apache-2.0 OR MIT"

[badges]
travis-ci = { repository = "andrewtc/mode", branch = "master" }

[dependencies]
8 changes: 7 additions & 1 deletion src/automaton.rs
Original file line number Diff line number Diff line change
Expand Up @@ -154,14 +154,20 @@ impl<'a, Base> Automaton<'a, Base>
/// `Transition` is returned, the `Transition` callback will be called on the current `Mode`, swapping in whichever
/// `Mode` it returns as a result.
///
/// For convenience, this function returns a `bool` representing whether a `Transition` was performed or not. A
/// result of `true` indicates that the `Automaton` transitioned to another `Mode`. If no `Transition` was performed
/// and the previous `Mode` is still active, returns `false`.
///
/// See [`Transition`](trait.Transition.html) and
/// [`Mode::get_transition()`](trait.Mode.html#tymethod.get_transition) for more details.
///
pub fn perform_transitions(&mut self) {
pub fn perform_transitions(&mut self) -> bool {
if let Some(mode) = self.current_mode.perform_transitions() {
// If a transition was performed and a new `ModeWrapper` was returned, swap in the new `Mode`.
self.current_mode = mode;
true
}
else { false }
}

/// Returns an immutable reference to the current `Mode` as a `&Self::Base`, allowing immutable functions to be
Expand Down

0 comments on commit a437c5b

Please sign in to comment.