wopt-0.3.8 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 *;
Field Attributes
For more information on how to use these attributes, refer to the structures in tests\common\mod.rs.
| Name | Description |
|---|---|
optional |
Force the optional version of the current struct to use the optional version of the current field. |
ser/de |
Specify methods of serialization/deserialization (if specified, both are required). |
serde |
Force the generated serialize/deserialize methods of the field (must derive WithOpt) to be used (usually paired with optional). |
required |
Does not wrap the specified field with an Option. |
skip |
Does not include the current field. |
Optional Feature(s)
| Name | Description |
|---|---|
bytemuck |
Serialize/Deserialize using bytemuck. |
unchecked |
Disable unwrap checks. |
Additional Notes
The automatically generated optional-struct does not come with any trait/derivation implementations. The fields are publicized, however, it may be helpful to specify the Default trait:
// attempts to implement `Default`
;