A derive macro for quickly implementing get_or_init
and get_mut
functions for structs that contain OnceCell
or OnceLock
structs.
To use the macro on a struct, you need to define an initialization function somewhere and specify it with the init
attribute.
For example:
```rust
struct ToBeDerived {
#[init(init_val)]
val: OnceCell
fn initval() -> String { "Some value".tostring() } ```
You can get the value of the field by calling the val()
function that is generated.
get_mut
.OnceLock
.