Skip to content

Commit

Permalink
fix(main.rs): Validate file extension
Browse files Browse the repository at this point in the history
- Follow cargo clippy suggestion:
- Use `is_some_and` instead of `map_or` to validate the file extension
- Print an error message and exit if the file extension is not `.xlsx`
  • Loading branch information
sangshuduo committed Nov 30, 2024
1 parent d008390 commit b8e9e06
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion cat_xlsx/src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ fn main() -> Result<(), Box<dyn Error>> {
// Validate file extension
if !path
.extension()
.map_or(false, |ext| ext.eq_ignore_ascii_case("xlsx"))
.is_some_and(|ext| ext.eq_ignore_ascii_case("xlsx"))
{
eprintln!("Error: File must have .xlsx extension");
std::process::exit(1);
Expand Down

0 comments on commit b8e9e06

Please sign in to comment.