Skip to content

Commit 9d835c3

Browse files
committed
cp: remove unnecessary unwrap
Had assumed our MSRV did not support let-chains; happy to stand corrected.
1 parent d436d9c commit 9d835c3

File tree

1 file changed

+2
-4
lines changed

1 file changed

+2
-4
lines changed

src/uu/cp/src/copydir.rs

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -204,10 +204,8 @@ 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(prefix) = context.root.components().next_back()
208+
&& let Ok(stripped) = descendant.strip_prefix(prefix)
211209
{
212210
descendant = stripped.to_path_buf();
213211
}

0 commit comments

Comments
 (0)