r/rust
r/rust
5
Posted by2 months ago
[ANN] match_deref. I made a proc-macro lib for long-awaited deref patterns
I made a proc-macro lib for long-awaited deref patterns! https://crates.io/crates/match_deref . Example:
use std::rc::Rc;
enum Value {
Nil,
Cons(Rc<Value>, Rc<Value>),
Symbol(String),
}
use Value::*;
let v: &Value = todo!();
match_deref::match_deref!{
match v {
Nil => todo!(),
Cons(Deref @ Symbol(Deref @ "quote"), Deref @ Cons(x, Deref @ Nil)) => todo!(),
_ => todo!(),
}
}
I think my library is invaluable in writing interpreters, compilers, provers etc.
There exists ongoing work to add deref patterns to rustc. But with my lib you can use them right now, in stable Rust.
This is my very first lib in crates.io
85% Upvoted
no comments yet
Be the first to share what you think!
About Community
A place for all things related to the Rust programming language—an open-source systems language that emphasizes performance, reliability, and productivity.
196k
Rustaceans
1.1k
Online
Created Dec 2, 2010
Similar to this post
- r/skyrimmods[SSE] scripts.zip archive in my data folder? (probably...100%48/10/2021
- r/rust[ANN] `debug_unwraps` experimental debug only unwrapping63%8Aug 23
- r/wallpaperengine[OC] My collab project with u/_clairerity_ , we created...100%19Jul 2
- r/unrealengine[HELP] Imported .fbx meshes(from Maya) have the wrong...100%49/11/2019
- r/emacs[ANN] alphapapa/salv.el: Local minor mode to save a...95%19Jul 3
- r/rustMinecraft running on a redstone CPU/GPU implemented in...99%5120h
- r/rustThe GAT stabilization PR just got merged99%781d
- r/rustIntuitive: A crate for writing TUIs declaratively98%311d
- r/rustLet's Code Asteroids in Rust with a First-Time Bevy User96%96d
- r/rust[media] ripdrag - Drag and Drop utility to make your...97%143d
- r/rustA personal list of Rust grievances95%1902d
- r/rustRust Foundation Establishes Security Team to Support and...98%402d
- r/rustDo most people just restart their Rust web servers once...93%1484d
- r/rustIs there a way to avoid call overhead?96%694d
- r/rustRust on Rails (write code that never crashes)96%876d
Reddit Inc © 2022. All rights reserved