summaryrefslogtreecommitdiff
path: root/embassy-hal-common
diff options
context:
space:
mode:
authorDario Nieuwenhuis <dirbaio@dirbaio.net>2022-07-22 16:06:45 +0200
committerDario Nieuwenhuis <dirbaio@dirbaio.net>2022-07-22 16:32:19 +0200
commitffbd9363f2a52fd27c81bbfbbe8e0e605a1ece86 (patch)
treef894f84ddebbac50ad4eb853e4686d76b242d6e1 /embassy-hal-common
parenta77ff721977e6071feb7000059d7e6185965949f (diff)
downloadembassy-ffbd9363f2a52fd27c81bbfbbe8e0e605a1ece86.zip
Change steal() from trait to inherent fns.
Diffstat (limited to 'embassy-hal-common')
-rw-r--r--embassy-hal-common/src/macros.rs24
1 files changed, 16 insertions, 8 deletions
diff --git a/embassy-hal-common/src/macros.rs b/embassy-hal-common/src/macros.rs
index 51e4a5ee..ffa5e4fb 100644
--- a/embassy-hal-common/src/macros.rs
+++ b/embassy-hal-common/src/macros.rs
@@ -8,9 +8,14 @@ macro_rules! peripherals {
pub struct $name { _private: () }
$(#[$cfg])?
- impl embassy::util::Steal for $name {
+ impl $name {
+ /// Unsafely create an instance of this peripheral out of thin air.
+ ///
+ /// # Safety
+ ///
+ /// You must ensure that you're only using one instance of this type at a time.
#[inline]
- unsafe fn steal() -> Self {
+ pub unsafe fn steal() -> Self {
Self{ _private: ()}
}
}
@@ -23,7 +28,6 @@ macro_rules! peripherals {
self
}
}
-
)*
}
@@ -48,23 +52,27 @@ macro_rules! peripherals {
panic!("init called more than once!")
}
_EMBASSY_DEVICE_PERIPHERALS = true;
- <Self as embassy::util::Steal>::steal()
+ Self::steal()
})
}
}
- impl embassy::util::Steal for Peripherals {
+ impl Peripherals {
+ /// Unsafely create an instance of this peripheral out of thin air.
+ ///
+ /// # Safety
+ ///
+ /// You must ensure that you're only using one instance of this type at a time.
#[inline]
- unsafe fn steal() -> Self {
+ pub unsafe fn steal() -> Self {
Self {
$(
$(#[$cfg])?
- $name: <peripherals::$name as embassy::util::Steal>::steal(),
+ $name: peripherals::$name::steal(),
)*
}
}
}
-
};
}