Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Default trait to Fe32 (derived) #184

Merged
merged 1 commit into from
Jul 31, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions api/all-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -144,6 +144,7 @@ impl core::convert::TryFrom<u16> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u32> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u64> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u8> for bech32::primitives::gf32::Fe32
impl core::default::Default for bech32::primitives::gf32::Fe32
impl core::error::Error for bech32::DecodeError
impl core::error::Error for bech32::EncodeError
impl core::error::Error for bech32::EncodeIoError
Expand Down Expand Up @@ -1009,6 +1010,7 @@ pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: &bech32::pri
pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32)
pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8
pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::default() -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: &bech32::primitives::gf32::Fe32)
Expand Down
2 changes: 2 additions & 0 deletions api/alloc-only.txt
Original file line number Diff line number Diff line change
Expand Up @@ -139,6 +139,7 @@ impl core::convert::TryFrom<u16> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u32> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u64> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u8> for bech32::primitives::gf32::Fe32
impl core::default::Default for bech32::primitives::gf32::Fe32
impl core::fmt::Debug for bech32::DecodeError
impl core::fmt::Debug for bech32::EncodeError
impl core::fmt::Debug for bech32::primitives::checksum::PackedNull
Expand Down Expand Up @@ -961,6 +962,7 @@ pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: &bech32::pri
pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32)
pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8
pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::default() -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: &bech32::primitives::gf32::Fe32)
Expand Down
2 changes: 2 additions & 0 deletions api/no-features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,7 @@ impl core::convert::TryFrom<u16> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u32> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u64> for bech32::primitives::gf32::Fe32
impl core::convert::TryFrom<u8> for bech32::primitives::gf32::Fe32
impl core::default::Default for bech32::primitives::gf32::Fe32
impl core::fmt::Debug for bech32::EncodeError
impl core::fmt::Debug for bech32::primitives::checksum::PackedNull
impl core::fmt::Debug for bech32::primitives::decode::CharError
Expand Down Expand Up @@ -892,6 +893,7 @@ pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: &bech32::pri
pub fn bech32::primitives::gf32::Fe32::add_assign(&mut self, other: bech32::primitives::gf32::Fe32)
pub fn bech32::primitives::gf32::Fe32::as_ref(&self) -> &u8
pub fn bech32::primitives::gf32::Fe32::clone(&self) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::default() -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: &bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div(self, other: bech32::primitives::gf32::Fe32) -> bech32::primitives::gf32::Fe32
pub fn bech32::primitives::gf32::Fe32::div_assign(&mut self, other: &bech32::primitives::gf32::Fe32)
Expand Down
8 changes: 7 additions & 1 deletion src/primitives/gf32.rs
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ const CHARS_INV: [i8; 128] = [
];

/// An element in GF(32), the finite field containing elements `[0,31]` inclusive.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Hash)]
#[derive(Copy, Clone, Debug, Default, PartialEq, Eq, Hash)]
#[repr(transparent)]
pub struct Fe32(pub(crate) u8);

Expand Down Expand Up @@ -487,6 +487,12 @@ mod tests {
assert_eq!(fe * Fe32::P, fe) // Fe32::P == Fe32(1)
}
}

#[test]
fn default() {
assert_eq!(Fe32::default().to_u8(), 0);
assert_eq!(Fe32::default(), Fe32::Q);
}
}

#[cfg(kani)]
Expand Down
Loading