lazy-wrap

Crates.iolazy-wrap
lib.rslazy-wrap
version0.4.1
sourcesrc
created_at2024-02-17 12:21:51.47025
updated_at2024-02-20 07:00:34.045783
descriptionLazily-initialised wrapper
homepage
repositoryhttps://github.com/Meadowsys/lazy-wrap.git
max_upload_size
id1143190
size6,570
Meadowsys (meadowsys)

documentation

README

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. This would look something like:

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

I've done my best, but its not tested for soundness, so use at your own risk. Please do file issues if you find any however, it would be very much appreciated c:

Commit count: 0

cargo fmt