aboutsummaryrefslogtreecommitdiff
path: root/src/lexical
diff options
context:
space:
mode:
Diffstat (limited to 'src/lexical')
-rw-r--r--src/lexical/algorithm.rs5
-rw-r--r--src/lexical/digit.rs5
-rw-r--r--src/lexical/errors.rs3
-rw-r--r--src/lexical/math.rs4
-rw-r--r--src/lexical/num.rs2
5 files changed, 7 insertions, 12 deletions
diff --git a/src/lexical/algorithm.rs b/src/lexical/algorithm.rs
index eaa5e7e..a2cbf18 100644
--- a/src/lexical/algorithm.rs
+++ b/src/lexical/algorithm.rs
@@ -51,10 +51,7 @@ where
// Compute the product of the power, if it overflows,
// prematurely return early, otherwise, if we didn't overshoot,
// we can get an exact value.
- let value = match mantissa.checked_mul(power) {
- None => return None,
- Some(value) => value,
- };
+ let value = mantissa.checked_mul(power)?;
if value >> mantissa_size != 0 {
None
} else {
diff --git a/src/lexical/digit.rs b/src/lexical/digit.rs
index 3d150a1..882aa9e 100644
--- a/src/lexical/digit.rs
+++ b/src/lexical/digit.rs
@@ -11,8 +11,5 @@ pub(crate) fn to_digit(c: u8) -> Option<u32> {
// Add digit to mantissa.
#[inline]
pub(crate) fn add_digit(value: u64, digit: u32) -> Option<u64> {
- match value.checked_mul(10) {
- None => None,
- Some(n) => n.checked_add(digit as u64),
- }
+ value.checked_mul(10)?.checked_add(digit as u64)
}
diff --git a/src/lexical/errors.rs b/src/lexical/errors.rs
index f4f41cd..cad4bd3 100644
--- a/src/lexical/errors.rs
+++ b/src/lexical/errors.rs
@@ -5,7 +5,8 @@
//! This estimates the error in a floating-point representation.
//!
//! This implementation is loosely based off the Golang implementation,
-//! found here: <https://golang.org/src/strconv/atof.go>
+//! found here:
+//! https://golang.org/src/strconv/atof.go
use super::float::*;
use super::num::*;
diff --git a/src/lexical/math.rs b/src/lexical/math.rs
index d7122bf..37cc1d2 100644
--- a/src/lexical/math.rs
+++ b/src/lexical/math.rs
@@ -336,7 +336,7 @@ mod small {
pub fn imul(x: &mut Vec<Limb>, y: Limb) {
// Multiply iteratively over all elements, adding the carry each time.
let mut carry: Limb = 0;
- for xi in &mut *x {
+ for xi in x.iter_mut() {
carry = scalar::imul(xi, y, carry);
}
@@ -482,7 +482,7 @@ mod small {
let rshift = bits - n;
let lshift = n;
let mut prev: Limb = 0;
- for xi in &mut *x {
+ for xi in x.iter_mut() {
let tmp = *xi;
*xi <<= lshift;
*xi |= prev >> rshift;
diff --git a/src/lexical/num.rs b/src/lexical/num.rs
index af10afd..e47e003 100644
--- a/src/lexical/num.rs
+++ b/src/lexical/num.rs
@@ -223,7 +223,7 @@ pub trait Float: Number {
const NEGATIVE_INFINITY_BITS: Self::Unsigned;
/// Size of the significand (mantissa) without hidden bit.
const MANTISSA_SIZE: i32;
- /// Bias of the exponent
+ /// Bias of the exponet
const EXPONENT_BIAS: i32;
/// Exponent portion of a denormal float.
const DENORMAL_EXPONENT: i32;