Skip to content

Commit

Permalink
remove unwraps from lib
Browse files Browse the repository at this point in the history
  • Loading branch information
tbillington committed Mar 12, 2023
1 parent 04f1adc commit 0f03a86
Showing 1 changed file with 4 additions and 7 deletions.
11 changes: 4 additions & 7 deletions kondo-lib/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
use std::{
borrow::Cow,
error::{self, Error},
fs, path,
time::SystemTime,
Expand Down Expand Up @@ -120,8 +121,8 @@ impl Project {
}
}

pub fn name(&self) -> String {
self.path.to_str().unwrap().to_string()
pub fn name(&self) -> Cow<str> {
self.path.to_string_lossy()
}

pub fn size(&self, options: &ScanOptions) -> u64 {
Expand Down Expand Up @@ -266,11 +267,7 @@ pub fn print_elapsed(secs: u64) -> String {
}

fn is_hidden(entry: &walkdir::DirEntry) -> bool {
entry
.file_name()
.to_str()
.map(|s| s.starts_with('.'))
.unwrap_or(false)
entry.file_name().to_string_lossy().starts_with('.')
}

struct ProjectIter {
Expand Down

0 comments on commit 0f03a86

Please sign in to comment.