optfield-lite 0.1.0

A macro to generate a new struct with fields wrapped in Option.
Documentation
  • Coverage
  • 100%
    2 out of 2 items documented1 out of 2 items with examples
  • Size
  • Source code size: 5.14 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 93.21 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Ø build duration
  • this release: 9s Average build duration of successful builds.
  • all releases: 9s Average build duration of successful builds in releases after 2024-10-23.
  • Links
  • PRO-2684/Candy-Pile
    3 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • PRO-2684

optfield-lite

GitHub License Crates.io Version Crates.io Total Downloads docs.rs free of syn

A macro to generate a new struct with fields wrapped in Option. Lite version of optfield.

Usage

Recommended to work with macro_rules_attr, which provides nice syntactic sugar:

use optfield_lite::optfield;
use macro_rules_attr::apply;

#[apply(optfield(OptTest))]
/// My test struct
struct Test {
    pub a: u32,
    b: u32,
}

This will generate a struct OptTest with the following fields:

/// My test struct
struct OptTest {
    pub a: Option<u32>,
    b: Option<u32>,
}

Note that the generated struct will have the same attributes and visibility as the original struct. You can also use it directly, which produces the same result:

use optfield_lite::optfield;

optfield! {
    /// My test struct
    struct Test {
        pub a: u32,
        b: u32,
    }(OptTest)
}

Comparison