Story

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

LoganFlaherty Thursday, February 19, 2026

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.
    }
}

Summary
Banish is an open-source software tool that allows users to block or hide unwanted content on websites, providing a customizable and ad-free browsing experience. The project aims to empower users to take control of their online experience and reduce the impact of intrusive advertisements and tracking.
2 0
Summary
github.com
Visit article Read on Hacker News