error[E0515]: cannot return reference to temporary value
--> src/lib.rs:8:9
|
8 | &Self::GET
| ^---------
| ||
| |temporary value created here
| returns a reference to data owned by the current function
For more information about this error, try `rustc --explain E0515`.
I know some types with destructors that can be put in constant, like Vec<T>, which makes itself cannot be static. But is there some trait bound that can constrain a type to must have no destructor, to prevent something like Vec<T> , make this example compile? Thanks.
TLDR: generic static variables are not supported -- static items are top level items, even if they were defined inside the scope of (generic) functions.
the reason you can take a 'static reference to a constant of concrete types, is because constant promotion occurs. a generic type CANNOT be promoted.