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 0b8219a commit a8eedd7Copy full SHA for a8eedd7
src/peripherals/singletons.md
@@ -65,8 +65,15 @@ use cortex_m::singleton;
65
66
fn main() {
67
// OK if `main` is executed only once
68
- let x: &'static mut bool =
69
- singleton!(: bool = false).unwrap();
+ let peripherals: &'static mut Peripherals =
+ singleton!(: Peripherals = Peripherals {
70
+ serial: Some(SerialPort),
71
+ })
72
+ .expect("Peripherals already taken!");
73
+
74
+ let serial_1 = peripherals.take_serial();
75
+ // This panics!
76
+ // let serial_2 = peripherals.take_serial();
77
}
78
```
79
0 commit comments