Skip to content

Commit

Permalink
feat(primitives): implement ops::Not for fixed bytes (#650)
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes authored Jun 6, 2024
1 parent 5ef8d4c commit 72a8dd5
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
10 changes: 10 additions & 0 deletions crates/primitives/src/bits/fixed.rs
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,16 @@ impl<const N: usize> ops::BitXorAssign for FixedBytes<N> {
}
}

impl<const N: usize> ops::Not for FixedBytes<N> {
type Output = Self;

#[inline]
fn not(mut self) -> Self::Output {
self.iter_mut().for_each(|byte| *byte = !*byte);
self
}
}

impl<const N: usize> str::FromStr for FixedBytes<N> {
type Err = hex::FromHexError;

Expand Down
1 change: 1 addition & 0 deletions crates/primitives/src/bits/macros.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ macro_rules! wrap_fixed_bytes {
$crate::private::derive_more::BitOrAssign,
$crate::private::derive_more::BitXor,
$crate::private::derive_more::BitXorAssign,
$crate::private::derive_more::Not,
$crate::private::derive_more::Deref,
$crate::private::derive_more::DerefMut,
$crate::private::derive_more::From,
Expand Down

0 comments on commit 72a8dd5

Please sign in to comment.