rust/src/doc/unstable-book/src/language-features/rvalue-static-promotion.md

551 B

rvalue_static_promotion

The tracking issue for this feature is: #38865


The rvalue_static_promotion feature allows directly creating 'static references to constant rvalues, which in particular allowing for more concise code in the common case in which a 'static reference is all that's needed.

Examples

#![feature(rvalue_static_promotion)]

fn main() {
    let DEFAULT_VALUE: &'static u32 = &42;
    assert_eq!(*DEFAULT_VALUE, 42);
}