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.
Posted Aug 1, 2024 15:02 UTC (Thu)
by tialaramex (subscriber, #21167)
[Link]
Don't worry, I was never under the impression it was *impossible* even when I started (long before 1.70) I was just expecting to need a third party crate to make this tidy and now probably I won't.
There's a lot more work to do to properly approach the vision from the Java API but in a nicer language, but I think I'm closing on the point where it's a useful alternative to tools like the Unix "basic calculator" bc or the typical GUI calculator on your desktop OS.
size_of and align_of