upa

Crates.ioupa
lib.rsupa
version0.1.0
sourcesrc
created_at2023-03-22 20:48:42.518229
updated_at2023-03-22 20:48:42.518229
descriptionMacro that removes the hassle of creating long pointer chains
homepage
repositoryhttps://github.com/ItsEthra/upa
max_upload_size
id817471
size3,833
Ethra (ItsEthra)

documentation

README

Upa

Macro that removes the hassle of creating long pointer chains.

Installation

[dependencies]
upa = "0.1.0"

Usage

struct Foo {
    bar: *mut Bar,
}

struct Bar {
    quz: *mut Quz,
}

struct Quz {
    tau: *mut Tau,
}

struct Tau {
    val: i32,
}

use upa::p;

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);
    }
}
Commit count: 2

cargo fmt