holder_derive

Crates.ioholder_derive
lib.rsholder_derive
version0.14.0
sourcesrc
created_at2024-07-07 10:20:00.541899
updated_at2024-07-18 00:13:09.946614
descriptiongetter setter auto gen with holder trait
homepage
repositoryhttps://github.com/Bruce0203/holder
max_upload_size
id1294689
size8,600
(Bruce0203)

documentation

README

holder

getter setter auto gen with holder trait

example

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);
}
Commit count: 16

cargo fmt