Crates.io | upa |
lib.rs | upa |
version | 0.1.0 |
source | src |
created_at | 2023-03-22 20:48:42.518229 |
updated_at | 2023-03-22 20:48:42.518229 |
description | Macro that removes the hassle of creating long pointer chains |
homepage | |
repository | https://github.com/ItsEthra/upa |
max_upload_size | |
id | 817471 |
size | 3,833 |
Macro that removes the hassle of creating long pointer chains.
[dependencies]
upa = "0.1.0"
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);
}
}