Today I did some tests on the nightly module std::lazy. It works well in local variable. However, when I defined a const variable, it gave me two different values. Seems the Colsure is called multiple times.
#![feature(once_cell)]
use rand::Rng; // 0.8.4
use std::lazy::Lazy;
const CONST_LAZY: Lazy<i32> = Lazy::new(|| rand::thread_rng().gen::<i32>());
fn main() {
let local_lazy: Lazy<i32> = Lazy::new(|| rand::thread_rng().gen::<i32>());
println!("{}", *local_lazy); // -1475423855
println!("{}", *local_lazy); // -1475423855
println!("{}", *CONST_LAZY); // 1975106939
println!("{}", *CONST_LAZY); // -1848043613
}