holder

Crates.ioholder
lib.rsholder
version0.14.0
sourcesrc
created_at2024-07-07 10:20:09.271743
updated_at2024-07-18 00:14:34.723568
descriptiongetter setter auto gen with holder trait
homepage
repositoryhttps://github.com/Bruce0203/holder
max_upload_size
id1294690
size4,368
(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