Crates.io | rukt |
lib.rs | rukt |
version | 0.2.4 |
source | src |
created_at | 2024-11-13 21:05:19.080695 |
updated_at | 2024-11-19 01:03:33.59085 |
description | Simple Rust dialect for token-based compile-time scripting |
homepage | |
repository | https://github.com/vberlier/rukt |
max_upload_size | |
id | 1447076 |
size | 81,805 |
Rust dialect for token-based compile-time scripting.
use rukt::rukt;
rukt! {
pub(crate) let operations = {
add: +,
sub: -,
mul: *,
div: /,
};
}
rukt! {
let {$($name:ident: $operator:tt,)*} = operations;
expand {
$(
fn $name(a: u32, b: u32) -> u32 {
a $operator b
}
)*
}
}
Rukt is a subset of Rust where you manipulate tokens instead of values.
It executes entirely at compile-time. It lets you store arbitrary token trees in variables, operate on these token trees using ordinary expressions and control flow, and substitute them anywhere in regular Rust code.
Rukt is designed to be as unsurprising as possible. It ports well-established Rust idioms to the realm of macro_rules
using polished syntax you're already used to.
This is a lightweight, no-dependency crate, backed entirely by declarative macros. There's no procedural macro involved. No unstable features.
Licensed under MIT or Apache-2.0.