Skip to content

Commit 79e8653

Browse files
committed
No need to use Default
1 parent 515906a commit 79e8653

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

library/core/src/num/mod.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -971,7 +971,7 @@ pub enum FpCategory {
971971

972972
#[doc(hidden)]
973973
trait FromStrRadixHelper:
974-
PartialOrd + Copy + Default + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self>
974+
PartialOrd + Copy + Add<Output = Self> + Sub<Output = Self> + Mul<Output = Self>
975975
{
976976
const MIN: Self;
977977
fn from_u32(u: u32) -> Self;
@@ -1039,7 +1039,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
10391039
return Err(PIE { kind: Empty });
10401040
}
10411041

1042-
let is_signed_ty = T::default() > T::MIN;
1042+
let is_signed_ty = T::from_u32(0) > T::MIN;
10431043

10441044
// all valid digits are ascii, so we will just iterate over the utf8 bytes
10451045
// and cast them to chars. .to_digit() will safely return None for anything
@@ -1056,7 +1056,7 @@ fn from_str_radix<T: FromStrRadixHelper>(src: &str, radix: u32) -> Result<T, Par
10561056
_ => (true, src),
10571057
};
10581058

1059-
let mut result = T::default();
1059+
let mut result = T::from_u32(0);
10601060

10611061
if can_not_overflow::<T>(radix, is_signed_ty, digits) {
10621062
// If the len of the str is short compared to the range of the type

0 commit comments

Comments
 (0)