Crates.io | holder_derive |
lib.rs | holder_derive |
version | 0.14.0 |
source | src |
created_at | 2024-07-07 10:20:00.541899 |
updated_at | 2024-07-18 00:13:09.946614 |
description | getter setter auto gen with holder trait |
homepage | |
repository | https://github.com/Bruce0203/holder |
max_upload_size | |
id | 1294689 |
size | 8,600 |
holder
getter setter auto gen with holder trait
use holder::{Holder, Holdable};
#[derive(Holder)]
struct Wrapper {
#[hold]
value: Token
}
#[derive(Holdable)]
struct Token(u32);
#[test]
fn holder_test() {
let mut wrapper = Wrapper { value: Token(123) };
let token: &Token = wrapper.token();
let token_mut: &mut Token = wrapper.token_mut();
}
fn holder_test_2<T: TokenHolder>(mut holder: T) {
*holder.token_mut() = Token(123);
}