From 9bab4175eb4120612e07470d060d6aca3b5edfd5 Mon Sep 17 00:00:00 2001
From: Jorge Aparicio <jorge@japaric.io>
Date: Sat, 9 Dec 2017 10:55:45 +0100
Subject: [PATCH] s/all/take/g s/_all/steal/g

---
 src/peripheral/mod.rs | 8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/src/peripheral/mod.rs b/src/peripheral/mod.rs
index c9c7a28..7482398 100644
--- a/src/peripheral/mod.rs
+++ b/src/peripheral/mod.rs
@@ -62,23 +62,25 @@ pub struct Peripherals {
     pub TPIU: TPIU,
 }
 
+// NOTE `no_mangle` is used here to prevent linking different minor versions of this crate as that
+// would let you `take` the core peripherals more than once (one per minor version)
 #[no_mangle]
 static mut CORE_PERIPHERALS: bool = false;
 
 impl Peripherals {
     /// Returns all the core peripherals *once*
-    pub fn all() -> Option<Self> {
+    pub fn take() -> Option<Self> {
         interrupt::free(|_| {
             if unsafe { CORE_PERIPHERALS } {
                 None
             } else {
-                Some(unsafe { Peripherals::_all() })
+                Some(unsafe { Peripherals::steal() })
             }
         })
     }
 
     #[doc(hidden)]
-    pub unsafe fn _all() -> Self {
+    pub unsafe fn steal() -> Self {
         debug_assert!(!CORE_PERIPHERALS);
 
         CORE_PERIPHERALS = true;
-- 
GitLab