diff --git a/src/peripherals/singletons.md b/src/peripherals/singletons.md index 1f3a556e..6d267ab8 100644 --- a/src/peripherals/singletons.md +++ b/src/peripherals/singletons.md @@ -65,8 +65,15 @@ use cortex_m::singleton; fn main() { // OK if `main` is executed only once - let x: &'static mut bool = - singleton!(: bool = false).unwrap(); + let peripherals: &'static mut Peripherals = + singleton!(: Peripherals = Peripherals { + serial: Some(SerialPort), + }) + .expect("Peripherals already taken!"); + + let serial_1 = peripherals.take_serial(); + // This panics! + // let serial_2 = peripherals.take_serial(); } ```