Under What Circumstances Does Rust Promote a Value to a 'static Lifetime?
The Rust Programming Language Forum
Under What Circumstances Does Rust Promote a Value to a 'static Lifetime?
I’m developing a compiler and recently came across something I’m not completely sure about. example: enum Foo { A, B, } An AI told me that values like Foo::A can be promoted to a 'static lifetime because they don’t contain any data: let x: &'static Foo = &Foo::A; Is this correct? If so, what are the conditions under which Rust performs constant promotion and allows a value to have a 'static reference?
0 comments
No comments yet.