I do kinda think something not entirely unlike lazy_static
should be in std, but not just because the crate is heavily used. Rather, my concern is that it's commonly needed and the stdlib does have something for it (std::sync::Once
) but you need to write unsafe
blocks to use it. I actually wrote a proposal quite some time ago.
(This isn't to say that the stdlib has to provide safe wrappers for every unsafe primitive it offers; but when the stdlib offers an unsafe primitive, and there could be a straightforward safe wrapper for at least 80% of what people use that unsafe primitive for, I think there's a strong case that the stdlib should offer that wrapper.)