nrf: add Unborrow<Target = Self> bound to all instance traits

This commit is contained in:
Dario Nieuwenhuis 2021-05-15 00:05:32 +02:00
parent 8394603ea6
commit a5ad79927e
8 changed files with 11 additions and 10 deletions

View file

@ -331,7 +331,7 @@ pub(crate) mod sealed {
pub trait OptionalPin {}
}
pub trait Pin: sealed::Pin + Sized {
pub trait Pin: Unborrow<Target = Self> + sealed::Pin + Sized {
/// Number of the pin within the port (0..31)
#[inline]
fn pin(&self) -> u8 {
@ -435,7 +435,7 @@ fn init_output<T: Pin>(pin: &T, drive: OutputDrive) {
// ====================
pub trait OptionalPin: sealed::OptionalPin + Sized {
pub trait OptionalPin: Unborrow<Target = Self> + sealed::OptionalPin + Sized {
type Pin: Pin;
fn pin(&self) -> Option<&Self::Pin>;
fn pin_mut(&mut self) -> Option<&mut Self::Pin>;

View file

@ -211,7 +211,7 @@ pub(crate) mod sealed {
}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}

View file

@ -383,7 +383,7 @@ pub(crate) mod sealed {
}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}

View file

@ -3,7 +3,7 @@ use core::sync::atomic::{compiler_fence, AtomicU32, Ordering};
use critical_section::CriticalSection;
use embassy::interrupt::InterruptExt;
use embassy::time::Clock;
use embassy::util::CriticalSectionMutex as Mutex;
use embassy::util::{CriticalSectionMutex as Mutex, Unborrow};
use crate::interrupt::Interrupt;
use crate::pac;
@ -283,7 +283,7 @@ macro_rules! impl_instance {
}
/// Implemented by all RTC instances.
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
/// The interrupt associated with this RTC instance.
type Interrupt: Interrupt;
}

View file

@ -349,7 +349,7 @@ pub(crate) mod sealed {
}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}

View file

@ -1,6 +1,7 @@
#![macro_use]
use embassy::interrupt::Interrupt;
use embassy::util::Unborrow;
use crate::pac;
@ -13,7 +14,7 @@ pub(crate) mod sealed {
pub trait ExtendedInstance {}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}
pub trait ExtendedInstance: Instance + sealed::ExtendedInstance {}

View file

@ -509,7 +509,7 @@ pub(crate) mod sealed {
}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}

View file

@ -469,7 +469,7 @@ pub(crate) mod sealed {
}
}
pub trait Instance: sealed::Instance + 'static {
pub trait Instance: Unborrow<Target = Self> + sealed::Instance + 'static {
type Interrupt: Interrupt;
}