lazy-scoped 0.1.0

Super-simple scoped single-threaded lazily-initialised objects
Documentation
  • Coverage
  • 0%
    0 out of 4 items documented0 out of 3 items with examples
  • Size
  • Source code size: 2.79 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 274.13 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • eira-fransham

Lazy

Super-simple scoped lazily-initialised objects, because eager evaluation is for dopes. I am frankly shocked that there is no crate that does this and compiles on any current version of Rust.

Serving suggestion:

let lazy = Lazy::new(|| {
	println!("Doing something complicated!");
	42
});

println!("{}", *lazy);
println!("{}", *lazy);
println!("{}", *lazy);

/* Prints:
 *   Doing something complicated!
 *   42
 *   42
 *   42
 */

Currently implemented with RefCell, but it will not panic. This class is not thread-safe, the project I made it for will eventually need it to be though, so I'll probably update it to use something thread-safe eventually.