Crate upa

Source
Expand description

§Upa - macro that removes the hassle of creating long pointer chains.

That’s right, you won’t see (*(*(*(*p).a).b).c).d stuff in your unsafe coded ever again.

fn main() {
    let mut t = Tau { val: 1337 };
    let mut q = Quz { tau: &mut t };
    let mut b = Bar { quz: &mut q };
    let f: *mut Foo = &mut Foo { bar: &mut b };

    unsafe {
        let wow = p!(f->bar->quz->tau->val);
        assert_eq!(wow, 1337);
    }
}

P.S. Identifier is the only item allowed in between ->.

Macros§

p
Makes all of your problems go away.