Skip to content

Commit 8f30944

Browse files
committed
Change Debug to match Display
The derived `Debug` showed the raw digit data, which is sometimes useful if you're debugging `num-bigint` itself, but annoying in many other contexts. For something like a simple `dbg!` call in a program, you probably just want to see the numeric value. This is not _necessarily_ a breaking change, but we'll treat it so.
1 parent 72810a5 commit 8f30944

File tree

2 files changed

+12
-2
lines changed

2 files changed

+12
-2
lines changed

src/bigint.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ impl Neg for Sign {
5959
}
6060

6161
/// A big signed integer type.
62-
#[derive(Debug)]
6362
pub struct BigInt {
6463
sign: Sign,
6564
data: BigUint,
@@ -137,6 +136,12 @@ impl Default for BigInt {
137136
}
138137
}
139138

139+
impl fmt::Debug for BigInt {
140+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
141+
fmt::Display::fmt(self, f)
142+
}
143+
}
144+
140145
impl fmt::Display for BigInt {
141146
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
142147
f.pad_integral(!self.is_negative(), "", &self.data.to_str_radix(10))

src/biguint.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,6 @@ pub(crate) use self::convert::to_str_radix_reversed;
3535
pub use self::iter::{U32Digits, U64Digits};
3636

3737
/// A big unsigned integer type.
38-
#[derive(Debug)]
3938
pub struct BigUint {
4039
data: Vec<BigDigit>,
4140
}
@@ -106,6 +105,12 @@ impl Default for BigUint {
106105
}
107106
}
108107

108+
impl fmt::Debug for BigUint {
109+
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
110+
fmt::Display::fmt(self, f)
111+
}
112+
}
113+
109114
impl fmt::Display for BigUint {
110115
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
111116
f.pad_integral(true, "", &self.to_str_radix(10))

0 commit comments

Comments
 (0)