lazy-wrap 0.2.0

Lazily-initialised wrapper
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# lazy-wrap

Smol wrapper around a type with an attached initialisation function. On first access, it'll call the attached function to initialise the value. Implements `Deref` and `DerefMut`.

You can create this in a `static` variable. I've not really found any easier solution than to take a `&'static dyn Fn() -> T` as default type for `F` for the initialiser, so you would need to borrow on your closure. This would look something like:

```rs
static STATIC_STRING: LazyWrap<String> = LazyWrap::new(&|| {
   // do whatever
   "hallo!!!".into()
});
```

Please file issues if you find any, they would be very much appreciated c: