lazy-st 1.0.0

Single-threaded lazy evaluation
Documentation
  • Coverage
  • 90%
    9 out of 10 items documented6 out of 9 items with examples
  • Size
  • Source code size: 10.04 kB This is the summed size of all the files inside the crates.io package for this release.
  • Documentation size: 563.68 kB This is the summed size of all files generated by rustdoc for all configured targets
  • Links
  • 01mf02/lazy-st
    1 0 0
  • crates.io
  • Dependencies
  • Versions
  • Owners
  • 01mf02

lazy-st

This crate provides single-threaded lazy evaluation for Rust. It is an adaptation of the lazy crate, removing support for multi-threaded operation, adding support for no_std environments, and making it compatible with newer Rust versions.

To share lazy values between threads, please consider using the lazy-mt crate.

Example

fn expensive() -> i32 {
    println!("I am only evaluated once!"); 7
}

fn main() {
    let a = lazy!(expensive());

    // Thunks are just smart pointers!
    assert_eq!(*a, 7); // "I am only evaluated once!" is printed here

    let b = [*a, *a]; // Nothing is printed.
    assert_eq!(b, [7, 7]);
}