| Crates.io | easylazy |
| lib.rs | easylazy |
| version | 0.2.0 |
| created_at | 2023-11-09 15:54:56.39715+00 |
| updated_at | 2024-07-03 17:44:48.297982+00 |
| description | Easy lazy initialization of variables |
| homepage | https://github.com/ciresnave/easylazy |
| repository | https://github.com/ciresnave/easylazy |
| max_upload_size | |
| id | 1030246 |
| size | 11,946 |
NOTE: Do not use this! LazyCell has been standardized and is better!
Looking at the available options for lazy initialization, I found that the most required jumping through odd, unnecessary hoops. EasyLazy aims to make lazy initialization of a variable lightweight and easy.
EasyLazy has only 3 requirements:
use easylazy::Lazy;
let mut my_lazy_variable = Lazy::new(Box::new(|| 10));
// my_lazy_variable is uninitialized here
assert_eq!(my_lazy_variable.get(), 10);
my_lazy_variable.get_mut() = 20;
assert_eq!(my_lazy_variable.get(), 20);