wopt 0.1.2

A procedural macro that automatically generates an Option-wrapped version of a struct, reducing boilerplate for optional updates.
Documentation
wopt-0.1.2 has been yanked.

wopt (with-options)

Description

A procedural macro that automatically generates an Option-wrapped version of a struct, reducing boilerplate for optional updates.

Example

use wopt::*;

#[derive(WithOpt)]
#[wopt(derive(Debug, Clone, PartialEq))]
struct Example {
    a: u8,
    b: f32,
    c: String,
}

#[test]
fn main() {
    let mut ex_opt = ExampleOpt::default();
    ex_opt.b = Some(420.0);

    assert_eq!(
        ex_opt,
        ExampleOpt {
            a: None,
            b: Some(420.0),
            c: None
        },
    )
}

Optional Features

Name Description
rkyv Serialize/Deserialize using rkyv
serde Seriailze/Deserialize using serde