diff options
| author | Dario Nieuwenhuis <[email protected]> | 2022-07-22 15:21:35 +0200 |
|---|---|---|
| committer | Dario Nieuwenhuis <[email protected]> | 2022-07-23 01:33:22 +0200 |
| commit | 715fa5146840a81b0ecbf35852eb3a7caf741e83 (patch) | |
| tree | 8cdbf8acbf81b2fd81fc68eabd299ff60ecce737 | |
| parent | bff0ad9286ea219d0e19855b8ed8ba3e1a0f1bdf (diff) | |
Reuse unsafe_impl_unborrow in other macros.
| -rw-r--r-- | embassy-hal-common/src/macros.rs | 11 | ||||
| -rw-r--r-- | embassy-macros/src/macros/cortex_m_interrupt_declare.rs | 10 |
2 files changed, 2 insertions, 19 deletions
diff --git a/embassy-hal-common/src/macros.rs b/embassy-hal-common/src/macros.rs index d693308be..115325c82 100644 --- a/embassy-hal-common/src/macros.rs +++ b/embassy-hal-common/src/macros.rs | |||
| @@ -21,16 +21,7 @@ macro_rules! peripherals { | |||
| 21 | } | 21 | } |
| 22 | 22 | ||
| 23 | $(#[$cfg])? | 23 | $(#[$cfg])? |
| 24 | unsafe impl $crate::Unborrow for $name { | 24 | $crate::unsafe_impl_unborrow!($name); |
| 25 | type Target = $name; | ||
| 26 | #[inline] | ||
| 27 | fn unborrow<'a>(self) -> $crate::Unborrowed<'a, Self::Target> | ||
| 28 | where | ||
| 29 | Self: 'a, | ||
| 30 | { | ||
| 31 | $crate::Unborrowed::new(self) | ||
| 32 | } | ||
| 33 | } | ||
| 34 | )* | 25 | )* |
| 35 | } | 26 | } |
| 36 | 27 | ||
diff --git a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs index 9d1e4af54..7eaaf6097 100644 --- a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs +++ b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs | |||
| @@ -25,15 +25,7 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> { | |||
| 25 | } | 25 | } |
| 26 | } | 26 | } |
| 27 | 27 | ||
| 28 | unsafe impl ::embassy_hal_common::Unborrow for #name_interrupt { | 28 | ::embassy_hal_common::unsafe_impl_unborrow!(#name_interrupt); |
| 29 | type Target = #name_interrupt; | ||
| 30 | fn unborrow<'a>(self) -> ::embassy_hal_common::Unborrowed<'a, #name_interrupt> | ||
| 31 | where | ||
| 32 | Self: 'a | ||
| 33 | { | ||
| 34 | ::embassy_hal_common::Unborrowed::new(self) | ||
| 35 | } | ||
| 36 | } | ||
| 37 | }; | 29 | }; |
| 38 | Ok(result) | 30 | Ok(result) |
| 39 | } | 31 | } |
