diff --git a/src/dp.rs b/src/dp.rs index 0565b5545..e35eef6a9 100644 --- a/src/dp.rs +++ b/src/dp.rs @@ -17,6 +17,7 @@ use num_bigint::{BigInt, BigUint, TryFromBigIntError}; use num_rational::{BigRational, Ratio}; use serde::{Deserialize, Serialize}; +use std::fmt; /// Errors propagated by methods in this module. #[derive(Debug, thiserror::Error)] @@ -42,6 +43,12 @@ pub enum DpError { #[derive(Clone, Debug, Serialize, Deserialize, PartialEq, Eq)] pub struct Rational(Ratio); +impl fmt::Display for Rational { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + write!(f, "{}", self.0) + } +} + impl Rational { /// Construct a [`Rational`] number from numerator `n` and denominator `d`. Errors if denominator is zero. pub fn from_unsigned(n: T, d: T) -> Result