Skip to content

Commit 9bab417

Browse files
committed
s/all/take/g s/_all/steal/g
1 parent c6ed9ef commit 9bab417

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/peripheral/mod.rs

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -62,23 +62,25 @@ pub struct Peripherals {
6262
pub TPIU: TPIU,
6363
}
6464

65+
// NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
66+
// would let you `take` the core peripherals more than once (one per minor version)
6567
#[no_mangle]
6668
static mut CORE_PERIPHERALS: bool = false;
6769

6870
impl Peripherals {
6971
/// Returns all the core peripherals *once*
70-
pub fn all() -> Option<Self> {
72+
pub fn take() -> Option<Self> {
7173
interrupt::free(|_| {
7274
if unsafe { CORE_PERIPHERALS } {
7375
None
7476
} else {
75-
Some(unsafe { Peripherals::_all() })
77+
Some(unsafe { Peripherals::steal() })
7678
}
7779
})
7880
}
7981

8082
#[doc(hidden)]
81-
pub unsafe fn _all() -> Self {
83+
pub unsafe fn steal() -> Self {
8284
debug_assert!(!CORE_PERIPHERALS);
8385

8486
CORE_PERIPHERALS = true;

0 commit comments

Comments
 (0)