Skip to content

Commit 3854a97

Browse files
committed
seq: remove unused Number::num_digits() function
Remove the `Number::num_digits()` function in favor of the `digits::num_integral_digits()` functions.
1 parent 2ac5dc0 commit 3854a97

File tree

1 file changed

+0
-52
lines changed

1 file changed

+0
-52
lines changed

src/uu/seq/src/seq.rs

Lines changed: 0 additions & 52 deletions
Original file line numberDiff line numberDiff line change
@@ -67,38 +67,6 @@ impl Number {
6767
Number::F64(n) => n,
6868
}
6969
}
70-
71-
/// Number of characters needed to print the integral part of the number.
72-
///
73-
/// The number of characters includes one character to represent the
74-
/// minus sign ("-") if this number is negative.
75-
///
76-
/// # Examples
77-
///
78-
/// ```rust,ignore
79-
/// use num_bigint::{BigInt, Sign};
80-
///
81-
/// assert_eq!(
82-
/// Number::BigInt(BigInt::new(Sign::Plus, vec![123])).num_digits(),
83-
/// 3
84-
/// );
85-
/// assert_eq!(
86-
/// Number::BigInt(BigInt::new(Sign::Minus, vec![123])).num_digits(),
87-
/// 4
88-
/// );
89-
/// assert_eq!(Number::F64(123.45).num_digits(), 3);
90-
/// assert_eq!(Number::MinusZero.num_digits(), 2);
91-
/// ```
92-
fn num_digits(&self) -> usize {
93-
match self {
94-
Number::MinusZero => 2,
95-
Number::BigInt(n) => n.to_string().len(),
96-
Number::F64(n) => {
97-
let s = n.to_string();
98-
s.find('.').unwrap_or_else(|| s.len())
99-
}
100-
}
101-
}
10270
}
10371

10472
impl FromStr for Number {
@@ -404,23 +372,3 @@ fn print_seq_integers(
404372
}
405373
Ok(())
406374
}
407-
408-
#[cfg(test)]
409-
mod tests {
410-
use crate::Number;
411-
use num_bigint::{BigInt, Sign};
412-
413-
#[test]
414-
fn test_number_num_digits() {
415-
assert_eq!(
416-
Number::BigInt(BigInt::new(Sign::Plus, vec![123])).num_digits(),
417-
3
418-
);
419-
assert_eq!(
420-
Number::BigInt(BigInt::new(Sign::Minus, vec![123])).num_digits(),
421-
4
422-
);
423-
assert_eq!(Number::F64(123.45).num_digits(), 3);
424-
assert_eq!(Number::MinusZero.num_digits(), 2);
425-
}
426-
}

0 commit comments

Comments
 (0)