Skip to content

Commit

Permalink
change Debug format
Browse files Browse the repository at this point in the history
  • Loading branch information
plafer committed Nov 16, 2023
1 parent 08f9d9d commit 9b91a1e
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 3 deletions.
8 changes: 7 additions & 1 deletion math/src/field/f128/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ const ELEMENT_BYTES: usize = core::mem::size_of::<u128>();
///
/// Internal values are stored in their canonical form in the range [0, M). The backing type is
/// `u128`.
#[derive(Copy, Clone, Debug, PartialEq, Eq, Default)]
#[derive(Copy, Clone, PartialEq, Eq, Default)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(transparent))]
pub struct BaseElement(u128);
Expand Down Expand Up @@ -196,6 +196,12 @@ impl Randomizable for BaseElement {
}
}

impl Debug for BaseElement {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self)
}
}

impl Display for BaseElement {
fn fmt(&self, f: &mut Formatter) -> core::fmt::Result {
write!(f, "{}", self.0)
Expand Down
8 changes: 7 additions & 1 deletion math/src/field/f62/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ const G: u64 = 4421547261963328785;
///
/// Internal values are stored in Montgomery representation and can be in the range [0; 2M). The
/// backing type is `u64`.
#[derive(Copy, Clone, Debug, Default)]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(from = "u64", into = "u64"))]
pub struct BaseElement(u64);
Expand Down Expand Up @@ -233,6 +233,12 @@ impl Randomizable for BaseElement {
}
}

impl Debug for BaseElement {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self)
}
}

impl Display for BaseElement {
fn fmt(&self, f: &mut Formatter) -> core::fmt::Result {
write!(f, "{}", self.as_int())
Expand Down
8 changes: 7 additions & 1 deletion math/src/field/f64/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ const ELEMENT_BYTES: usize = core::mem::size_of::<u64>();
///
/// Internal values represent x * R mod M where R = 2^64 mod M and x in [0, M).
/// The backing type is `u64` but the internal values are always in the range [0, M).
#[derive(Copy, Clone, Debug, Default)]
#[derive(Copy, Clone, Default)]
#[cfg_attr(feature = "serde", derive(Deserialize, Serialize))]
#[cfg_attr(feature = "serde", serde(from = "u64", into = "u64"))]
pub struct BaseElement(u64);
Expand Down Expand Up @@ -296,6 +296,12 @@ impl Randomizable for BaseElement {
}
}

impl Debug for BaseElement {
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
write!(f, "{}", self)
}
}

impl Display for BaseElement {
fn fmt(&self, f: &mut Formatter) -> core::fmt::Result {
write!(f, "{}", self.as_int())
Expand Down

0 comments on commit 9b91a1e

Please sign in to comment.