aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-extras/src/macros.rs16
-rw-r--r--embassy-macros/src/lib.rs7
-rw-r--r--embassy/src/util/mod.rs18
3 files changed, 7 insertions, 34 deletions
diff --git a/embassy-extras/src/macros.rs b/embassy-extras/src/macros.rs
index fba752619..351938c42 100644
--- a/embassy-extras/src/macros.rs
+++ b/embassy-extras/src/macros.rs
@@ -24,14 +24,6 @@ macro_rules! peripherals {
24 } 24 }
25 } 25 }
26 26
27 $(#[$cfg])?
28 impl embassy::util::Unborrow for &mut $name {
29 type Target = $name;
30 #[inline]
31 unsafe fn unborrow(self) -> $name {
32 ::core::ptr::read(self)
33 }
34 }
35 )* 27 )*
36 } 28 }
37 29
@@ -95,14 +87,6 @@ macro_rules! impl_unborrow {
95 self 87 self
96 } 88 }
97 } 89 }
98
99 impl<'a> ::embassy::util::Unborrow for &'a mut $type {
100 type Target = $type;
101 #[inline]
102 unsafe fn unborrow(self) -> Self::Target {
103 unsafe { ::core::ptr::read(self) }
104 }
105 }
106 }; 90 };
107} 91}
108 92
diff --git a/embassy-macros/src/lib.rs b/embassy-macros/src/lib.rs
index c2f928b93..ac856bef6 100644
--- a/embassy-macros/src/lib.rs
+++ b/embassy-macros/src/lib.rs
@@ -216,13 +216,6 @@ pub fn interrupt_declare(item: TokenStream) -> TokenStream {
216 self 216 self
217 } 217 }
218 } 218 }
219
220 impl ::embassy::util::Unborrow for &mut #name_interrupt {
221 type Target = #name_interrupt;
222 unsafe fn unborrow(self) -> #name_interrupt {
223 ::core::ptr::read(self)
224 }
225 }
226 }; 219 };
227 result.into() 220 result.into()
228} 221}
diff --git a/embassy/src/util/mod.rs b/embassy/src/util/mod.rs
index 7de15d4ad..8057e120e 100644
--- a/embassy/src/util/mod.rs
+++ b/embassy/src/util/mod.rs
@@ -22,6 +22,13 @@ pub trait Unborrow {
22 unsafe fn unborrow(self) -> Self::Target; 22 unsafe fn unborrow(self) -> Self::Target;
23} 23}
24 24
25impl<'a, T: Unborrow> Unborrow for &'a mut T {
26 type Target = T::Target;
27 unsafe fn unborrow(self) -> Self::Target {
28 T::unborrow(core::ptr::read(self))
29 }
30}
31
25pub trait Steal { 32pub trait Steal {
26 unsafe fn steal() -> Self; 33 unsafe fn steal() -> Self;
27} 34}
@@ -40,17 +47,6 @@ macro_rules! impl_unborrow_tuples {
40 } 47 }
41 } 48 }
42 49
43 impl<'a, $($t),+> Unborrow for &'a mut($($t),+)
44 where
45 $(
46 $t: Unborrow<Target = $t>
47 ),+
48 {
49 type Target = ($($t),+);
50 unsafe fn unborrow(self) -> Self::Target {
51 ::core::ptr::read(self)
52 }
53 }
54 50
55 }; 51 };
56} 52}