Skip to content

Commit 46d43fe

Browse files
committed
Add more trait bounds
1 parent d1c6c22 commit 46d43fe

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

src/observable.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@ pub trait ObservationLock: Sized + crate::Sealed {
1111
/// preventing things like a an observed gpio pin changing mode or an opamp from
1212
/// being disabled. This makes sure the underlaying peripheral will not
1313
/// change mode into something that is not compatible with what ever may be observing it.
14-
pub struct Observed<P, const OBSERVER_COUNT: usize> {
14+
pub struct Observed<P: Observable, const OBSERVER_COUNT: usize> {
1515
peripheral: P,
1616
}
1717

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

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

57-
impl<P, const N: usize> AsRef<P> for Observed<P, N> {
57+
impl<P: Observable, const N: usize> AsRef<P> for Observed<P, N> {
5858
fn as_ref(&self) -> &P {
5959
&self.peripheral
6060
}
6161
}
6262

63-
impl<P, const N: usize> AsMut<P> for Observed<P, N> {
63+
impl<P: Observable, const N: usize> AsMut<P> for Observed<P, N> {
6464
fn as_mut(&mut self) -> &mut P {
6565
&mut self.peripheral
6666
}

0 commit comments

Comments
 (0)