Crates.io | invade_derive |
lib.rs | invade_derive |
version | 0.0.6 |
source | src |
created_at | 2024-02-12 22:26:54.943415 |
updated_at | 2024-02-14 01:31:01.94848 |
description | A library to reflect on Rust types and generate code |
homepage | |
repository | https://github.com/KABBOUCHI/invade |
max_upload_size | |
id | 1137369 |
size | 6,328 |
cargo add invade
use invade::invade;
#[invade]
struct Counter {
count: u32,
}
#[invade]
impl Counter {
fn inc(&mut self) {
self.count += 1;
}
}
fn main() {
let mut counter = Counter { count: 0 };
println!("count: {:?}", counter.invade_get::<u32>("count"));
counter.invade_set("count", 1_u32);
assert_eq!(counter.count, 1);
counter.invade_call("inc", vec![]);
assert_eq!(counter.count, 2);
}