]> git.lizzy.rs Git - rust.git/blobdiff - clippy_utils/src/numeric_literal.rs
Address internal lints
[rust.git] / clippy_utils / src / numeric_literal.rs
index 98f65039b7da9fb2765e72d7a6f6e44bd8ab077f..68dd1b29845a570cc4f6b30af834414fc34d70c5 100644 (file)
@@ -74,7 +74,7 @@ pub fn new(lit: &'a str, suffix: Option<&'a str>, float: bool) -> Self {
         };
 
         // Grab part of the literal after prefix, if present.
-        let (prefix, mut sans_prefix) = if let Radix::Decimal = radix {
+        let (prefix, mut sans_prefix) = if radix == Radix::Decimal {
             (None, lit)
         } else {
             let (p, s) = lit.split_at(2);
@@ -157,8 +157,10 @@ pub fn format(&self) -> String {
         }
 
         if let Some((separator, exponent)) = self.exponent {
-            output.push_str(separator);
-            Self::group_digits(&mut output, exponent, group_size, true, false);
+            if exponent != "0" {
+                output.push_str(separator);
+                Self::group_digits(&mut output, exponent, group_size, true, false);
+            }
         }
 
         if let Some(suffix) = self.suffix {
@@ -179,7 +181,7 @@ pub fn group_digits(output: &mut String, input: &str, group_size: usize, partial
 
         // The exponent may have a sign, output it early, otherwise it will be
         // treated as a digit
-        if let Some('-') = digits.clone().next() {
+        if digits.clone().next() == Some('-') {
             let _ = digits.next();
             output.push('-');
         }