https://github.com/vberlier/rukt
Rust dialect for token-based compile-time scripting
https://github.com/vberlier/rukt
compile-time macros rust
Last synced: 6 months ago
JSON representation
Rust dialect for token-based compile-time scripting
- Host: GitHub
- URL: https://github.com/vberlier/rukt
- Owner: vberlier
- License: apache-2.0
- Created: 2024-11-13T18:14:50.000Z (11 months ago)
- Default Branch: main
- Last Pushed: 2024-11-19T01:03:38.000Z (11 months ago)
- Last Synced: 2025-03-27T07:02:04.596Z (6 months ago)
- Topics: compile-time, macros, rust
- Language: Rust
- Homepage:
- Size: 43 KB
- Stars: 1
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- Funding: .github/FUNDING.yml
- License: LICENSE-APACHE
Awesome Lists containing this project
README
# rukt
[](https://github.com/vberlier/rukt/actions/workflows/test.yml)
[](https://github.com/vberlier/rukt/blob/main/LICENSE-MIT)
[](https://crates.io/crates/rukt)
[](https://crates.io/crates/rukt)
[](https://docs.rs/rukt)Rust dialect for token-based compile-time scripting.
```rust
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
}
)*
}
}
```# Introduction
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](https://doc.rust-lang.org/reference/macros-by-example.html). There's no procedural macro involved. No unstable features.
## Documentation
- [Statements](https://docs.rs/rukt/latest/rukt/eval/macro.block.html)
- [Expressions](https://docs.rs/rukt/latest/rukt/eval/macro.expression.html)
- [Operators](https://docs.rs/rukt/latest/rukt/eval/macro.operator.html)
- [Builtins](https://docs.rs/rukt/latest/rukt/builtins/index.html)
- [Internals](https://docs.rs/rukt/latest/rukt/eval/index.html)## License
Licensed under [MIT](https://github.com/vberlier/rukt/blob/main/LICENSE-MIT) or [Apache-2.0](https://github.com/vberlier/rukt/blob/main/LICENSE-APACHE).