#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

#8 in #holder

Download history 120/week @ 2024-07-16 37/week @ 2024-07-23 25/week @ 2024-07-30 6/week @ 2024-09-10 2/week @ 2024-09-17 25/week @ 2024-09-24 3/week @ 2024-10-01

597 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
~21K SLoC