Skip to content

jFransham/lazy-scoped

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

8 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages