6 releases (3 breaking)

0.4.1 Feb 20, 2024
0.4.0 Feb 20, 2024
0.3.1 Feb 18, 2024
0.2.0 Feb 18, 2024
0.1.0 Feb 17, 2024

#13 in #smol

Download history 371/week @ 2024-02-17 65/week @ 2024-02-24 6/week @ 2024-03-02 26/week @ 2024-03-09 4/week @ 2024-03-16 36/week @ 2024-03-30 7/week @ 2024-04-06

51 downloads per month
Used in 2 crates (via string-pool)

MIT license

6KB
144 lines

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:

Dependencies

~0.4–6.5MB
~11K SLoC