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