From 715fa5146840a81b0ecbf35852eb3a7caf741e83 Mon Sep 17 00:00:00 2001 From: Dario Nieuwenhuis Date: Fri, 22 Jul 2022 15:21:35 +0200 Subject: [PATCH] Reuse unsafe_impl_unborrow in other macros. --- embassy-hal-common/src/macros.rs | 11 +---------- .../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 d693308b..115325c8 100644 --- a/embassy-hal-common/src/macros.rs +++ b/embassy-hal-common/src/macros.rs @@ -21,16 +21,7 @@ macro_rules! peripherals { } $(#[$cfg])? - unsafe impl $crate::Unborrow for $name { - type Target = $name; - #[inline] - fn unborrow<'a>(self) -> $crate::Unborrowed<'a, Self::Target> - where - Self: 'a, - { - $crate::Unborrowed::new(self) - } - } + $crate::unsafe_impl_unborrow!($name); )* } diff --git a/embassy-macros/src/macros/cortex_m_interrupt_declare.rs b/embassy-macros/src/macros/cortex_m_interrupt_declare.rs index 9d1e4af5..7eaaf609 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 { } } - unsafe impl ::embassy_hal_common::Unborrow for #name_interrupt { - type Target = #name_interrupt; - fn unborrow<'a>(self) -> ::embassy_hal_common::Unborrowed<'a, #name_interrupt> - where - Self: 'a - { - ::embassy_hal_common::Unborrowed::new(self) - } - } + ::embassy_hal_common::unsafe_impl_unborrow!(#name_interrupt); }; Ok(result) }