We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 94c065e commit 6c807cbCopy full SHA for 6c807cb
src/mem/global_static/lazy-constant.md
@@ -40,14 +40,16 @@ fn main() {
40
```rust,edition2021
41
use std::cell::OnceCell;
42
43
-let cell = OnceCell::new();
44
-assert!(cell.get().is_none());
45
-
46
-let value: &String = cell.get_or_init(|| {
47
- "Hello, World!".to_string()
48
-});
49
-assert_eq!(value, "Hello, World!");
50
-assert!(cell.get().is_some());
+fn main() {
+ let cell = OnceCell::new();
+ assert!(cell.get().is_none());
+
+ let value: &String = cell.get_or_init(|| {
+ "Hello, World!".to_string()
+ });
+ assert_eq!(value, "Hello, World!");
51
+ assert!(cell.get().is_some());
52
+}
53
```
54
55
[`OnceCell`]: https://doc.rust-lang.org/beta/std/cell/struct.OnceCell.html
0 commit comments