Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

singleton

A value of which only one can ever exist, such as the one handle to a chip's GPIO8 pin.

In embedded Rust a peripheral singleton is the unique value of a peripheral's type, handed out once by the HAL (esp_hal::init returns Peripherals), so ownership of the value is ownership of the hardware.

Examples

  • esp_hal::init returns Peripherals once, and its GPIO8 field is the only handle to the fan pin; a second init call panics.

  • If the heater setup is copy-pasted from the fan's and still names peripherals.GPIO8, the compiler rejects it because GPIO8 was already moved into the fan.

Read the full section →