11 breaking releases

0.14.0 Jul 18, 2024
0.11.0 Jul 8, 2024

#929 in Rust patterns

Download history 73/week @ 2024-07-23 35/week @ 2024-07-30 5/week @ 2024-09-10 47/week @ 2024-09-24 1/week @ 2024-10-01

587 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.6–1MB
~21K SLoC