| Crates.io | specx |
| lib.rs | specx |
| version | 0.1.0 |
| created_at | 2025-11-24 14:04:34.005468+00 |
| updated_at | 2025-11-24 14:04:34.005468+00 |
| description | Minimal Specification pattern utilities for Rust with composable predicate specs, boolean combinators, and a micro-DSL. |
| homepage | https://github.com/simbiont666/specx |
| repository | https://github.com/simbiont666/specx |
| max_upload_size | |
| id | 1947916 |
| size | 27,193 |
specx is a tiny, zero-dependency crate implementing the Specification pattern with ergonomic boolean combinators and a lightweight macro DSL.
spec!(A & (B | !C)).spec_fn(|x| ...).use specx::{Specification, spec};
struct IsAdult;
struct IsAdmin;
struct User {
age: u8,
is_admin: bool,
}
impl Specification<User> for IsAdult {
fn is_satisfied_by(&self, u: &User) -> bool { u.age >= 18 }
}
impl Specification<User> for IsAdmin {
fn is_satisfied_by(&self, u: &User) -> bool { u.is_admin }
}
let combined = spec!(IsAdult & !IsAdmin);
let u = User { age: 20, is_admin: false };
assert!(combined.is_satisfied_by(&u));