Error code E0158
An associated const has been referenced in a pattern.
Erroneous code example:
ⓘ
const
and static
mean different things. A const
is a compile-time
constant, an alias for a literal value. This property means you can match it
directly within a pattern.
The static
keyword, on the other hand, guarantees a fixed location in memory.
This does not always mean that the value is constant. For example, a global
mutex can be declared static
as well.
If you want to match against a static
, consider using a guard instead: