Skip to content

Commit

Permalink
Fixup iface common, require default bound
Browse files Browse the repository at this point in the history
  • Loading branch information
SpinFast committed Nov 30, 2023
1 parent 9adc253 commit 9bd032e
Showing 1 changed file with 6 additions and 4 deletions.
10 changes: 6 additions & 4 deletions src/generate/iface/common.rs
Original file line number Diff line number Diff line change
Expand Up @@ -53,21 +53,23 @@ impl<'a, I, K: Copy, V, A: Access> Reg<'a, I, K, V, A> {
}
}

impl<'a, I: Interface<K, V>, K: Copy, V: Copy, A: Read> Reg<'a, I, K, V, A> {
impl<'a, I: Interface<K, V>, K: Copy, V, A: Read> Reg<'a, I, K, V, A> {
#[inline(always)]
pub fn read(&mut self) -> Result<V, I::Error> {
self.iface.read(self.addr)
}
}

impl<'a, I: Interface<K, V>, K: Copy, V: Copy, A: Write> Reg<'a, I, K, V, A> {
impl<'a, I: Interface<K, V>, K: Copy, V, A: Write> Reg<'a, I, K, V, A> {
#[inline(always)]
pub fn write_value(&mut self, val: V) -> Result<(), I::Error> {
self.iface.write(self.addr, val)
}
}

impl<'a, I: Interface<K, V>, K: Copy, V: Default + Copy, A: Write> Reg<'a, I, K, V, A> {
impl<'a, I: Interface<K, V>, K: Copy, V: Copy + core::default::Default, A: Write>
Reg<'a, I, K, V, A>
{
#[inline(always)]
pub fn write<R>(&mut self, f: impl FnOnce(&mut V) -> R) -> Result<R, I::Error> {
let mut val = Default::default();
Expand All @@ -77,7 +79,7 @@ impl<'a, I: Interface<K, V>, K: Copy, V: Default + Copy, A: Write> Reg<'a, I, K,
}
}

impl<'a, I: Interface<K, V>, K: Copy, V: Copy, A: Read + Write> Reg<'a, I, K, V, A> {
impl<'a, I: Interface<K, V>, K: Copy, V, A: Read + Write> Reg<'a, I, K, V, A> {
#[inline(always)]
pub fn modify<R>(&mut self, f: impl FnOnce(&mut V) -> R) -> Result<R, I::Error> {
let mut val = self.read()?;
Expand Down

0 comments on commit 9bd032e

Please sign in to comment.