Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,6 +41,9 @@ jobs:
- name: Run tests
run: cargo test --manifest-path core/Cargo.toml

- name: Check docs
run: RUSTDOCFLAGS="-D warnings" cargo doc --manifest-path core/Cargo.toml --no-deps

build:
name: Build release binary
runs-on: ${{ matrix.os }}
Expand Down
12 changes: 6 additions & 6 deletions core/src/flow.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,20 +4,20 @@ use crate::error::{Result, SteplockError};

#[derive(Debug, Clone)]
pub struct FlowGraph {
/// States reachable from [*] (the initial states).
/// States reachable from `[*]` (the initial states).
pub initial: Vec<String>,
/// Outgoing transitions per state. States that go to [*] map to vec!["[*]"].
/// Outgoing transitions per state. States that go to `[*]` map to `vec!["[*]"]`.
pub transitions: HashMap<String, Vec<String>>,
/// Human-readable label per state.
pub labels: HashMap<String, String>,
/// States with a transition to [*] (terminal states).
/// States with a transition to `[*]` (terminal states).
pub terminal: HashSet<String>,
/// Topological order of non-pseudo states (for preview output).
pub order: Vec<String>,
}

impl FlowGraph {
/// Returns states that are not yet visited and not the pseudo [*] node.
/// Returns states that are not yet visited and not the pseudo `[*]` node.
pub fn pending_after(&self, visited: &[String]) -> Vec<String> {
let visited_set: HashSet<&str> = visited.iter().map(|s| s.as_str()).collect();
self.order
Expand All @@ -27,15 +27,15 @@ impl FlowGraph {
.collect()
}

/// Outgoing transitions from `state`, excluding [*].
/// Outgoing transitions from `state`, excluding `[*]`.
pub fn next_states(&self, state: &str) -> Vec<String> {
self.transitions
.get(state)
.map(|v| v.iter().filter(|s| s.as_str() != "[*]").cloned().collect())
.unwrap_or_default()
}

/// True if `state` is a terminal state (transitions to [*]).
/// True if `state` is a terminal state (transitions to `[*]`).
pub fn is_terminal(&self, state: &str) -> bool {
self.terminal.contains(state)
}
Expand Down
Loading