Apply suggestion from code review.

Co-authored-by: Jack Grigg <jack@electriccoin.co>
This commit is contained in:
Kris Nuttycombe 2024-12-14 14:55:10 -07:00 committed by GitHub
parent da444b1094
commit 3e529310af
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
1 changed files with 5 additions and 7 deletions

View File

@ -34,14 +34,12 @@ where
Some(uuid) => Ok(AccountUuid::from_uuid(uuid)),
None => {
let account_ids = db_data.get_account_ids()?;
if account_ids.len() > 1 {
Err(anyhow!(
match &account_ids[..] {
[] => Err(anyhow!("Wallet contains no accounts.")),
[account_id] => Ok(*account_id),
_ => Err(anyhow!(
"More than one account is available; please specify the account UUID."
))
} else {
account_ids
.first()
.map_or(Err(anyhow!("Wallet contains no accounts.")), |v| Ok(*v))
)),
}
}
}?;