Skip to content

Commit 9a8c8a5

Browse files
committed
cp: remove unnecessary unwrap
1 parent 9b1f458 commit 9a8c8a5

File tree

1 file changed

+5
-4
lines changed

1 file changed

+5
-4
lines changed

src/uu/cp/src/copydir.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,11 @@ impl Entry {
204204
translate!("cp-error-failed-to-create-directory", "error" => e)
205205
);
206206
}
207-
} else if let Ok(stripped) =
208-
// The following unwrap is unreachable because context.root is always *something*.
209-
descendant
210-
.strip_prefix(context.root.components().next_back().unwrap())
207+
} else if let Some(stripped) = context
208+
.root
209+
.components()
210+
.next_back()
211+
.and_then(|stripped| descendant.strip_prefix(stripped).ok())
211212
{
212213
descendant = stripped.to_path_buf();
213214
}

0 commit comments

Comments
 (0)