#getter-setter #holder #traits #gen #auto #derive

macro holder_derive

getter setter auto gen with holder trait

11 breaking releases

0.14.0 Jul 18, 2024
0.11.0 Jul 8, 2024

#7 in #holder

36 downloads per month
Used in holder

MIT license

9KB
149 lines

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–1.1MB
~22K SLoC