Crates.io | holder_derive |
lib.rs | holder_derive |
version | 0.12.0 |
source | src |
created_at | 2024-07-07 10:20:00.541899 |
updated_at | 2024-07-09 00:02:16.402468 |
description | getter setter auto gen with holder trait |
homepage | |
repository | https://github.com/Bruce0203/holder |
max_upload_size | |
id | 1294689 |
size | 9,780 |
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);
}