Finite state machines in rust; bendns fork to add types.
feature-gate DSL re-export
Yevhenii Babichenko 2021-02-24
parent 5c9aa45 · commit a224521
-rw-r--r--.github/workflows/tests.yml2
-rw-r--r--CHANGELOG.md3
-rw-r--r--Cargo.toml5
-rw-r--r--README.md11
-rw-r--r--src/lib.rs10
5 files changed, 21 insertions, 10 deletions
diff --git a/.github/workflows/tests.yml b/.github/workflows/tests.yml
index 2a34f15..65c1071 100644
--- a/.github/workflows/tests.yml
+++ b/.github/workflows/tests.yml
@@ -33,7 +33,7 @@ jobs:
uses: actions-rs/cargo@v1
with:
command: build
- args: --no-default-features
+ args: --no-default-features --features "dsl"
- name: Run tests
uses: actions-rs/cargo@v1
diff --git a/CHANGELOG.md b/CHANGELOG.md
index 276ac1f..beab444 100644
--- a/CHANGELOG.md
+++ b/CHANGELOG.md
@@ -5,6 +5,9 @@ The format is based on [Keep a Changelog][keepachangelog], and this project
adheres to [Semantic Versioning][semver].
## [Unreleased]
+### Added
+* The re-export of the DSL implementation is gated by the `dsl` feature which is
+ enabled by default.
### Changed
* State transition error is now represented with `TransitionImpossibleError`
instead of `()`.
diff --git a/Cargo.toml b/Cargo.toml
index 667db86..8bfce93 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -13,11 +13,12 @@ authors = ["Yevhenii Babichenko"]
edition = "2018"
[features]
-default = ["std"]
+default = ["std", "dsl"]
std = []
+dsl = ["rust-fsm-dsl"]
[dependencies]
-rust-fsm-dsl = { path = "./rust_fsm_dsl", version = "0.4.0" }
+rust-fsm-dsl = { path = "./rust_fsm_dsl", version = "0.4.0", optional = true }
[profile.dev]
panic = "abort"
diff --git a/README.md b/README.md
index 9474657..47f88dc 100644
--- a/README.md
+++ b/README.md
@@ -30,13 +30,16 @@ of state machines:
* A Moore machine by providing an output function that do not depend on the
provided inputs.
-## Usage in `no_std` environments
+## Features
This library has the feature named `std` which is enabled by default. You
may want to import this library as
-`rust-fsm = { version = "0.5", default-features = false }` to use it in a
-`no_std` environment. This only affects error types (the `Error` trait is
-only available in `std`).
+`rust-fsm = { version = "0.5", default-features = false, features = ["dsl"] }`
+to use it in a `no_std` environment. This only affects error types (the `Error`
+trait is only available in `std`).
+
+The DSL implementation re-export is gated by the feature named `dsl` which is
+also enabled by default.
## Use
diff --git a/src/lib.rs b/src/lib.rs
index 17b4e6b..e4c205c 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -31,9 +31,12 @@
//!
//! This library has the feature named `std` which is enabled by default. You
//! may want to import this library as
-//! `rust-fsm = { version = "0.5", default-features = false }` to use it in a
-//! `no_std` environment. This only affects error types (the `Error` trait is
-//! only available in `std`).
+//! `rust-fsm = { version = "0.5", default-features = false, features = ["dsl"] }`
+//! to use it in a `no_std` environment. This only affects error types (the
+//! `Error` trait is only available in `std`).
+//!
+//! The DSL implementation re-export is gated by the feature named `dsl` which
+//! is also enabled by default.
//!
//! # Use
//!
@@ -126,6 +129,7 @@ use core::fmt;
#[cfg(feature = "std")]
use std::error::Error;
+#[cfg(feature = "dsl")]
pub use rust_fsm_dsl::state_machine;
/// This trait is designed to describe any possible deterministic finite state