From 1d3c82282f7c6921183a9122b02264ffad9dfeec Mon Sep 17 00:00:00 2001 From: ilyalesokhin-starkware Date: Tue, 7 Jan 2025 16:03:43 +0200 Subject: [PATCH] Add fmt::Display to fields. (#322) --- .../crates/verifier_core/src/fields/cm31.cairo | 6 ++++++ .../crates/verifier_core/src/fields/m31.cairo | 6 ++++++ .../crates/verifier_core/src/fields/qm31.cairo | 6 ++++++ 3 files changed, 18 insertions(+) diff --git a/stwo_cairo_verifier/crates/verifier_core/src/fields/cm31.cairo b/stwo_cairo_verifier/crates/verifier_core/src/fields/cm31.cairo index 44832f16..2da897e3 100644 --- a/stwo_cairo_verifier/crates/verifier_core/src/fields/cm31.cairo +++ b/stwo_cairo_verifier/crates/verifier_core/src/fields/cm31.cairo @@ -122,6 +122,12 @@ impl CM31PartialOrd of PartialOrd { } } +impl DisplayCM31 of core::fmt::Display { + fn fmt(self: @CM31, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { + write!(f, "{} + {}i", self.a, self.b) + } +} + #[inline] pub fn cm31(a: u32, b: u32) -> CM31 { CM31 { a: m31(a), b: m31(b) } diff --git a/stwo_cairo_verifier/crates/verifier_core/src/fields/m31.cairo b/stwo_cairo_verifier/crates/verifier_core/src/fields/m31.cairo index ea51220f..fcf2a30d 100644 --- a/stwo_cairo_verifier/crates/verifier_core/src/fields/m31.cairo +++ b/stwo_cairo_verifier/crates/verifier_core/src/fields/m31.cairo @@ -251,6 +251,12 @@ pub impl M31SubConstrain0 of bounded_int::ConstrainHelper { + fn fmt(self: @M31, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { + self.inner.fmt(ref f) + } +} + #[cfg(test)] mod tests { use super::super::Invertible; diff --git a/stwo_cairo_verifier/crates/verifier_core/src/fields/qm31.cairo b/stwo_cairo_verifier/crates/verifier_core/src/fields/qm31.cairo index 543d951c..90b598a2 100644 --- a/stwo_cairo_verifier/crates/verifier_core/src/fields/qm31.cairo +++ b/stwo_cairo_verifier/crates/verifier_core/src/fields/qm31.cairo @@ -424,6 +424,12 @@ pub impl CM31IntoPackedUnreducedCM31 of Into { } } +impl DisplayQM31 of core::fmt::Display { + fn fmt(self: @QM31, ref f: core::fmt::Formatter) -> Result<(), core::fmt::Error> { + write!(f, "({}) + ({})u", self.a, self.b) + } +} + #[cfg(test)] mod tests { use super::super::Invertible;