Skip to content

Commit 45b4a5f

Browse files
committed
fix: fix code format when using 10 digits
1 parent 4151871 commit 45b4a5f

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

src/otp/otp_element.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -222,10 +222,10 @@ impl OTPElement {
222222

223223
fn format_code(&self, value: u32) -> Result<String, OtpError> {
224224
// Get the formatted code
225-
let exponential = 10_u32
225+
let exponential = 10_u64
226226
.checked_pow(self.digits as u32)
227227
.ok_or(OtpError::InvalidDigits)?;
228-
let s = (value % exponential).to_string();
228+
let s = (value as u64 % exponential).to_string();
229229
Ok("0".repeat(self.digits as usize - s.chars().count()) + s.as_str())
230230
}
231231
}

0 commit comments

Comments
 (0)