Reuse unsafe_impl_unborrow in other macros.

This commit is contained in:
Dario Nieuwenhuis 2022-07-22 15:21:35 +02:00
parent bff0ad9286
commit 715fa51468
2 changed files with 2 additions and 19 deletions

View File

@ -21,16 +21,7 @@ macro_rules! peripherals {
} }
$(#[$cfg])? $(#[$cfg])?
unsafe impl $crate::Unborrow for $name { $crate::unsafe_impl_unborrow!($name);
type Target = $name;
#[inline]
fn unborrow<'a>(self) -> $crate::Unborrowed<'a, Self::Target>
where
Self: 'a,
{
$crate::Unborrowed::new(self)
}
}
)* )*
} }

View File

@ -25,15 +25,7 @@ pub fn run(name: syn::Ident) -> Result<TokenStream, TokenStream> {
} }
} }
unsafe impl ::embassy_hal_common::Unborrow for #name_interrupt { ::embassy_hal_common::unsafe_impl_unborrow!(#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)
}
}
}; };
Ok(result) Ok(result)
} }