mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-28 09:44:08 +00:00
Improve the documentation for rvalue_static_promotion
This commit is contained in:
parent
20c0f323fc
commit
f06b04949f
@ -2,4 +2,22 @@
|
||||
|
||||
The tracking issue for this feature is: [#38865]
|
||||
|
||||
[#38865]: https://github.com/rust-lang/rust/issues/38865
|
||||
|
||||
------------------------
|
||||
|
||||
The `rvalue_static_promotion` feature allows directly creating `'static` references to
|
||||
constant `rvalue`s, which in particular allowing for more concise code in the common case
|
||||
in which a `'static` reference is all that's needed.
|
||||
|
||||
|
||||
## Examples
|
||||
|
||||
```rust
|
||||
#![feature(rvalue_static_promotion)]
|
||||
|
||||
fn main() {
|
||||
let DEFAULT_VALUE: &'static u32 = &42;
|
||||
assert_eq!(*DEFAULT_VALUE, 42);
|
||||
}
|
||||
```
|
||||
|
@ -12,4 +12,4 @@
|
||||
fn main() {
|
||||
let x: &'static u32 = &42; //~ error: does not live long enough
|
||||
let y: &'static Option<u32> = &None; //~ error: does not live long enough
|
||||
}
|
||||
}
|
||||
|
@ -14,4 +14,4 @@
|
||||
fn main() {
|
||||
let x: &'static u32 = &42;
|
||||
let y: &'static Option<u32> = &None;
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user