How are we supposed to declare safe static data currently?
As a new Rust programmer I've been using lazy_static
but encountered a problem with it. When I investigated, it turns out that lazy_static
is deprecated and we should use std::sync::LazyLock
instead ... except that that crate is marked unstable so can't be used with a stable version of the compiler.
So what am I supposed to do?
The problem with lazy_static
is that it seems to declare the object as having the same type as the name, rather than the declared type. Here for example, mime_html
is declared as having type mime_html
rather than &'static Mime
as written. It doesn't help to declare a type alias type MimeReference = &'static Mime
and use that.
Since lazy_static
is deprecated, I don't see much point in raising an issue. However, at the same time, the proposed replacement is not yet ready.