diff --git a/README.md b/README.md index 9b6fec9..a20257b 100644 --- a/README.md +++ b/README.md @@ -3,7 +3,7 @@ `matchbox::match_deref!{...}` is a procedural macro, which allows you to use deref patterns right now in stable Rust. For example: -```rust +```rust,no_run use std::rc::Rc; enum Value { @@ -33,24 +33,30 @@ I. e. it is possible that your arms are exhaustive, but the compiler will not be The macro calls `Deref::deref` internally. Keep in mind that `Deref::deref` takes REFERENCE to smart pointer and returns REFERENCE to pointee. So this code will work: `match &Nil { Deref @ x => ... }`, but this will not: `match Nil { Deref @ x => ... }`. Consider this code: -```rust +```rust,ignore matchbox::match_deref!{ match v { - Symbol(Deref @ x) => some_code_here, - _ => other_code_here, + Symbol(Deref @ x) => { + // some_code_here + } + _ => { + // other_code_here, + } } } ``` It will be desugared to something like this: -```rust +```rust,ignore match v { Symbol(a0) if (if let x = Deref::deref(a0) { true } else { false }) => if let x = Deref::deref(a0) { - some_code_here + // some_code_here } else { panic!() - }, - _ => other_code_here, + } + _ => { + // other_code_here + } } ```