Back to browse
GitHub Repository

A declarative framework for rule-based state machines in Rust.

114 starsRust

Banish – A declarative DSL for rule-based state machines in Rust

by LoganFlaherty·Feb 19, 2026·2 points·0 comments

AI Analysis

●●●BangerBig BrainWizardry

Fixed-point rule evaluation as a procedural macro; compiles to zero-overhead Rust, not a VM.

Strengths
  • Zero runtime overhead: macro expands to plain Rust, no interpreter or virtual machine penalty
  • Fixed-point solving elegantly expresses constraint/layout problems that normally need nested loops
  • Scope awareness lets you reference outer variables/functions directly; seamless integration into existing code
Weaknesses
  • Audience is niche: only relevant for devs building specific patterns (layout, constraint, game engines)
  • Minimal real-world examples shown; unclear how complex multi-domain logic scales vs handwritten code
Target Audience

Rust developers building layout engines, constraint solvers, game logic, or complex state machines

Similar To

Datalog engines · TLA+ temporal logic · Drools rule engine

Post Description

I’ve been working on a Rust macro called Banish for defining rule-based state machines declaratively.

Instead of manually writing transition loops, Banish evaluates rules within a state until no rule fires (a fixed-point model), then transitions. The macro expands into regular Rust, which allows for seamless integration.

The goal is to make complex rule logic and state machines easier to express while keeping runtime costs identical to handwritten code.

The project was featured as Crate of the Week in the Rust newsletter this week. I'd love to hear your feedback.

Example: use banish::banish;

fn main() { let buffer = ["No".to_string(), "hey".to_string()]; let target = "hey".to_string(); let idx = find_index(&buffer, &target); print!("{:?}", idx) }

fn find_index(buffer: &[String], target: &str) -> Option<usize> { let mut idx = 0; banish! { @search // This must be first to prevent out-of-bounds panic below. not_found ? idx >= buffer.len() { return None; }

found ? buffer[idx] != target { idx += 1; } !? { return Some(idx); } // Rule triggered so we re-evalutate rules in search. } }

Similar Projects

Infrastructure●●Solid

Raft in Rust

Sans-I/O Raft core with pluggable transport and storage traits.

Big BrainNiche Gem
carterburn
1023d ago
AI/MLPass

AEF – Agents State Machine

Two-commit spec repo with no working implementation or demo.

Ship It
mikemasam
103mo ago