[pbs-devel] [PATCH proxmox 05/19] tfa: remove needless `as_bytes` call
    Shannon Sterz 
    s.sterz at proxmox.com
       
    Thu Mar  6 13:43:35 CET 2025
    
    
  
len() already returns the length in bytes, no need to call `as_bytes`
first. this fixes a clippy lint [1].
[1]:
https://rust-lang.github.io/rust-clippy/master/index.html#needless_as_bytes
Signed-off-by: Shannon Sterz <s.sterz at proxmox.com>
---
 proxmox-tfa/src/totp.rs | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/proxmox-tfa/src/totp.rs b/proxmox-tfa/src/totp.rs
index 940af542..6be340c7 100644
--- a/proxmox-tfa/src/totp.rs
+++ b/proxmox-tfa/src/totp.rs
@@ -546,7 +546,7 @@ impl PartialEq<&str> for TotpValue {
     fn eq(&self, other: &&str) -> bool {
         // Since we use `from_str_radix` with a radix of 10 explicitly, we can check the number of
         // bytes against the number of digits.
-        if other.as_bytes().len() != (self.digits as usize) {
+        if other.len() != (self.digits as usize) {
             return false;
         }
 
-- 
2.39.5
    
    
More information about the pbs-devel
mailing list