Skip to content

Commit a44a6fd

Browse files
committed
fix: resolve clippy warnings for strip_prefix, cast, and const assertions
1 parent 7a3eb84 commit a44a6fd

3 files changed

Lines changed: 6 additions & 24 deletions

File tree

src/middleware/auth_guard.rs

Lines changed: 1 addition & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -14,11 +14,5 @@ pub fn extract_token_from_header(req: &ServiceRequest) -> Option<String> {
1414
req.headers()
1515
.get("Authorization")
1616
.and_then(|h| h.to_str().ok())
17-
.and_then(|h| {
18-
if h.starts_with("Bearer ") {
19-
Some(h[7..].to_string())
20-
} else {
21-
None
22-
}
23-
})
17+
.and_then(|h| h.strip_prefix("Bearer ").map(|s| s.to_string()))
2418
}

src/services/lockout_service.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -121,7 +121,7 @@ impl LockoutService {
121121
.set_ex(
122122
&lockout_key,
123123
locked_until.to_string(),
124-
self.lockout_duration as u64,
124+
self.lockout_duration,
125125
)
126126
.await?;
127127

src/services/totp_service.rs

Lines changed: 4 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -474,25 +474,13 @@ mod tests {
474474

475475
#[test]
476476
fn test_backup_code_count_is_reasonable() {
477-
assert!(
478-
BACKUP_CODE_COUNT >= 5,
479-
"Should have at least 5 backup codes"
480-
);
481-
assert!(
482-
BACKUP_CODE_COUNT <= 20,
483-
"Should have at most 20 backup codes"
484-
);
477+
const _: () = assert!(BACKUP_CODE_COUNT >= 5, "Should have at least 5 backup codes");
478+
const _: () = assert!(BACKUP_CODE_COUNT <= 20, "Should have at most 20 backup codes");
485479
}
486480

487481
#[test]
488482
fn test_backup_code_length_is_reasonable() {
489-
assert!(
490-
BACKUP_CODE_LENGTH >= 6,
491-
"Backup codes should be at least 6 chars"
492-
);
493-
assert!(
494-
BACKUP_CODE_LENGTH <= 16,
495-
"Backup codes should be at most 16 chars"
496-
);
483+
const _: () = assert!(BACKUP_CODE_LENGTH >= 6, "Backup codes should be at least 6 chars");
484+
const _: () = assert!(BACKUP_CODE_LENGTH <= 16, "Backup codes should be at most 16 chars");
497485
}
498486
}

0 commit comments

Comments
 (0)