extras: add impl_unborrow macro

This commit is contained in:
Dario Nieuwenhuis
2021-03-27 03:33:32 +01:00
parent 2c248dab56
commit a338841797
2 changed files with 24 additions and 27 deletions

View File

@ -84,3 +84,24 @@ macro_rules! unborrow {
)*
}
}
#[macro_export]
macro_rules! impl_unborrow {
($type:ident) => {
impl PeripheralBorrow for $type {
type Target = $type;
#[inline]
unsafe fn unborrow(self) -> Self::Target {
self
}
}
impl<'a> PeripheralBorrow for &'a mut $type {
type Target = $type;
#[inline]
unsafe fn unborrow(self) -> Self::Target {
unsafe { ::core::ptr::read(self) }
}
}
};
}