Radar · Rust · Archive · Week 8 · Feb 16 – 22, 2026
banish crate of the week
Nice to knowecosystem
- What changed
- The crate banish, a proc‑macro for building rule‑driven state machines, was highlighted.
- Production impact
- The source does not say.
- Try it
- Add
banishto a Cargo project and experiment with a simple state machine. - Source
- this-week-in-rust.org/blog/2026/02/18/this-week-in-rust-639/
Understand it, then run it
Run it now
// This example shows how you would normally implement a simple state machine
// without the banish crate. The banish macro would generate the same code
// automatically, but it is not available in Rust 1.98.1 (edition 2024).
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum State {
Idle,
Running,
Stopped,
}
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
enum Event {
Start,
Stop,
}
struct Machine {
state: State,
}
impl Machine {
fn new() -> Self {
Self { state: State::Idle }
}
fn step(&mut self, event: Event) {
self.state = match (self.state, event) {
(State::Idle, Event::Start) => State::Running,
(State::Running, Event::Stop) => State::Stopped,
// All other combinations leave the state unchanged
(s, _) => s,
};
}
}
fn main() {
let mut m = Machine::new();
println!("Initial state: {:?}", m.state);
m.step(Event::Start);
println!("After Start: {:?}", m.state);
m.step(Event::Stop);
println!("After Stop: {:?}", m.state);
}
What it printed when we ran it on Rust 1.98.1 (edition 2024)
Initial state: Idle After Start: Running After Stop: Stopped
Run sends this program (for Solidity, the contract and its tests) to our own sandbox, where it is compiled and run once, with no network, and what it printed or the test report comes back here. Nothing is kept. Runs are counted per visitor for the day so everyone gets a turn; the details are on the legal page.
Written by gpt-oss-20b from the linked source · claims checked against the sources · archive, not individually reviewed