[ANN] My proc macro lib for deref patterns we all waited so long!

I wrote proc macro lib, which implements deref patterns: https://crates.io/crates/match_deref . Right now, in stable Rust. Now you can write compilers, interpreters a lot easier!

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!(),
    }
}
4 Likes

Nice! :slightly_smiling_face:

Cool crate!
One thing that would be a nice addition is more examples.
The crates.io page mentions being able to match through a string,
and alludes to being able to do the same with other types.
Some examples for things like that would be greatly appreciated.