size_of and align_of
size_of and align_of
Posted Jul 28, 2024 2:23 UTC (Sun) by NYKevin (subscriber, #129325)In reply to: size_of and align_of by tialaramex
Parent article: Rust 1.80.0 released
(The main difference is that OnceCell and OnceLock require you to pass the lambda at each callsite, whereas LazyCell and LazyLock let you pass it once at construction time. The other difference is that LazyCell and LazyLock are Deref, so the callsite doesn't look like a callsite, it just looks like a pointer dereference - but you can call the force() associated function if you really want to be explicit about it. The really pedantic difference that probably nobody cares about, is that OnceCell and OnceLock can give you a mutable reference to the underlying data if you have mutably borrowed the OnceCell/OnceLock, but the Lazy objects don't let you do that.)
