Skip to content

Commit

Permalink
Add more trait bounds
Browse files Browse the repository at this point in the history
  • Loading branch information
usbalbin committed Dec 22, 2024
1 parent d1c6c22 commit 46d43fe
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/observable.rs
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ pub trait ObservationLock: Sized + crate::Sealed {
/// preventing things like a an observed gpio pin changing mode or an opamp from
/// being disabled. This makes sure the underlaying peripheral will not
/// change mode into something that is not compatible with what ever may be observing it.
pub struct Observed<P, const OBSERVER_COUNT: usize> {
pub struct Observed<P: Observable, const OBSERVER_COUNT: usize> {
peripheral: P,
}

Expand All @@ -29,7 +29,7 @@ impl<P: Observable, const OBSERVER_COUNT: usize> Observed<P, OBSERVER_COUNT> {
///
/// The existence of this type guarantees that the observed peripheral will not
/// change mode into something that is not compatibe with what ever is observing it
pub struct ObservationToken<P> {
pub struct ObservationToken<P: Observable> {
_p: PhantomData<P>,
}

Expand All @@ -54,13 +54,13 @@ impl<P: Observable + Sealed> ObservationLock for ObservationToken<P> {
type Peripheral = P;
}

impl<P, const N: usize> AsRef<P> for Observed<P, N> {
impl<P: Observable, const N: usize> AsRef<P> for Observed<P, N> {
fn as_ref(&self) -> &P {
&self.peripheral
}
}

impl<P, const N: usize> AsMut<P> for Observed<P, N> {
impl<P: Observable, const N: usize> AsMut<P> for Observed<P, N> {
fn as_mut(&mut self) -> &mut P {
&mut self.peripheral
}
Expand Down

0 comments on commit 46d43fe

Please sign in to comment.