Skip to content

Commit 18e95f5

Browse files
committed
Simplified control flow logic for the .strip_prefixs and used Path::to_str over UtfPath::to_str since we just want to skip the file, not error on it.
1 parent 3cacb96 commit 18e95f5

File tree

1 file changed

+5
-7
lines changed

1 file changed

+5
-7
lines changed

c2rust/src/main.rs

Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,13 +46,11 @@ impl SubCommand {
4646
continue;
4747
}
4848
let file_name = entry.file_name();
49-
let file_name: &Utf8Path = Path::new(&file_name).try_into()?;
50-
let file_name = file_name.as_str();
51-
let name = match file_name.strip_prefix(c2rust_name) {
52-
Some(name) => name,
53-
None => continue,
54-
};
55-
let name = match name.strip_prefix('-') {
49+
let name = match Path::new(&file_name)
50+
.to_str()
51+
.and_then(|name| name.strip_prefix(c2rust_name))
52+
.and_then(|name| name.strip_prefix('-'))
53+
{
5654
Some(name) => name,
5755
None => continue,
5856
};

0 commit comments

Comments
 (0)