Quoting: https://github.com/Pauan/rust-dominator/blob/master/examples/counter/src/lib.rs#L21-L25
static ROOT_CLASS: Lazy<String> = Lazy::new(|| class! {
.style("display", "inline-block")
.style("background-color", "black")
.style("padding", "10px")
});
Quoting Lazy in once_cell::sync - Rust
A value which is initialized on the first access. This type is thread-safe and can be used in statics.
Can someone please enlighten me on:
-
Why we need this to be
Lazy<String>
instead of regularString
? -
How once_cell::sync::Lazy differs from lazy_static!