11 breaking releases

0.14.0 Jul 18, 2024
0.11.0 Jul 8, 2024

#6 in #gen

Download history 44/week @ 2024-07-01 499/week @ 2024-07-08 112/week @ 2024-07-15 108/week @ 2024-07-29 5/week @ 2024-09-16 47/week @ 2024-09-23

52 downloads per month

MIT license

3KB

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);
}

Dependencies

~0.7–1.1MB
~23K SLoC