size_of and align_of
size_of and align_of
Posted Jul 29, 2024 2:58 UTC (Mon) by NYKevin (subscriber, #129325)In reply to: size_of and align_of by tialaramex
Parent article: Rust 1.80.0 released
fn make_small_bigint(value: i64) -> BigNum{
// Do whatever simple logic you need here.
}
// Can also have e.g. make_small_rational(numerator, denominator), etc.
// Global scope:
static OnceLock<BigNum> FOUR = OnceLock::new();
// Callsite:
let four = FOUR.get_or_init(|| make_small_bigint(4));
LazyLock just means you can write let four = *FOUR; instead of let four = FOUR.get_or_init(|| make_small_bigint(4));. You still have to write the function make_small_bigint() either way, because you will need to pass exactly the same lambda to the LazyLock at construction time.
