Skip to content

Commit

Permalink
Remove impl trait from parameter positions in Marshaller write methods
Browse files Browse the repository at this point in the history
Also remove from trait defintion - warning this can cause breaking changes
  • Loading branch information
samsarge committed Feb 4, 2025
1 parent 2fba304 commit 0693535
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 21 deletions.
14 changes: 7 additions & 7 deletions src/isa/bytecode.rs
Original file line number Diff line number Diff line change
Expand Up @@ -163,19 +163,19 @@ pub trait BytecodeWrite<Id: SiteId> {
}

/// Write a single bit.
fn write_1bit(&mut self, data: impl Into<u1>) -> Result<(), Self::Error>;
fn write_1bit(&mut self, data: u1) -> Result<(), Self::Error>;
/// Write two bits.
fn write_2bits(&mut self, data: impl Into<u2>) -> Result<(), Self::Error>;
fn write_2bits(&mut self, data: u2) -> Result<(), Self::Error>;
/// Write three bits.
fn write_3bits(&mut self, data: impl Into<u3>) -> Result<(), Self::Error>;
fn write_3bits(&mut self, data: u3) -> Result<(), Self::Error>;
/// Write four bits.
fn write_4bits(&mut self, data: impl Into<u4>) -> Result<(), Self::Error>;
fn write_4bits(&mut self, data: u4) -> Result<(), Self::Error>;
/// Write five bits.
fn write_5bits(&mut self, data: impl Into<u5>) -> Result<(), Self::Error>;
fn write_5bits(&mut self, data: u5) -> Result<(), Self::Error>;
/// Write six bits.
fn write_6bits(&mut self, data: impl Into<u6>) -> Result<(), Self::Error>;
fn write_6bits(&mut self, data: u6) -> Result<(), Self::Error>;
/// Write seven bits.
fn write_7bits(&mut self, data: impl Into<u7>) -> Result<(), Self::Error>;
fn write_7bits(&mut self, data: u7) -> Result<(), Self::Error>;

/// Write byte.
fn write_byte(&mut self, data: u8) -> Result<(), Self::Error>;
Expand Down
28 changes: 14 additions & 14 deletions src/library/marshaller.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,38 +365,38 @@ where
{
type Error = MarshallError;

fn write_1bit(&mut self, data: impl Into<u1>) -> Result<(), MarshallError> {
self.write(data.into().into_u8() as u32, u5::with(1))
fn write_1bit(&mut self, data: u1) -> Result<(), MarshallError> {
self.write(data.into_u8() as u32, u5::with(1))
.map_err(MarshallError::from)
}

fn write_2bits(&mut self, data: impl Into<u2>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(2))
fn write_2bits(&mut self, data: u2) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(2))
.map_err(MarshallError::from)
}

fn write_3bits(&mut self, data: impl Into<u3>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(3))
fn write_3bits(&mut self, data: u3) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(3))
.map_err(MarshallError::from)
}

fn write_4bits(&mut self, data: impl Into<u4>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(4))
fn write_4bits(&mut self, data: u4) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(4))

Check warning on line 384 in src/library/marshaller.rs

View check run for this annotation

Codecov / codecov/patch

src/library/marshaller.rs#L383-L384

Added lines #L383 - L384 were not covered by tests
.map_err(MarshallError::from)
}

fn write_5bits(&mut self, data: impl Into<u5>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(5))
fn write_5bits(&mut self, data: u5) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(5))

Check warning on line 389 in src/library/marshaller.rs

View check run for this annotation

Codecov / codecov/patch

src/library/marshaller.rs#L388-L389

Added lines #L388 - L389 were not covered by tests
.map_err(MarshallError::from)
}

fn write_6bits(&mut self, data: impl Into<u6>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(6))
fn write_6bits(&mut self, data: u6) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(6))

Check warning on line 394 in src/library/marshaller.rs

View check run for this annotation

Codecov / codecov/patch

src/library/marshaller.rs#L393-L394

Added lines #L393 - L394 were not covered by tests
.map_err(MarshallError::from)
}

fn write_7bits(&mut self, data: impl Into<u7>) -> Result<(), MarshallError> {
self.write(data.into().to_u8() as u32, u5::with(7))
fn write_7bits(&mut self, data: u7) -> Result<(), MarshallError> {
self.write(data.to_u8() as u32, u5::with(7))
.map_err(MarshallError::from)
}

Expand Down

0 comments on commit 0693535

Please sign in to comment.