Collapse nested if

Signed-off-by: Matthias Beyer <mail@beyermatthias.de>
This commit is contained in:
Matthias Beyer 2025-08-17 14:45:08 +02:00 committed by Fintan Halpenny
parent b0af48aa03
commit 787cb3a872
1 changed files with 2 additions and 4 deletions

View File

@ -246,10 +246,8 @@ impl Checkout {
.map_err(|err| CheckoutFailure::Payload { rid, err })?;
let path = directory.unwrap_or_else(|| PathBuf::from(proj.name()));
// N.b. fail if the path exists and is not empty
if path.exists() {
if path.read_dir().map_or(true, |mut dir| dir.next().is_some()) {
return Err(CheckoutFailure::Exists { rid, path });
}
if path.exists() && path.read_dir().map_or(true, |mut dir| dir.next().is_some()) {
return Err(CheckoutFailure::Exists { rid, path });
}
Ok(Self {