From 44f25d73b8f898e18aa7bcbee3bb87b2104d1f01 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sat, 31 Oct 2020 12:52:48 +0000 Subject: [PATCH] wip new accounts Signed-off-by: Ian Jackson --- src/accounts.rs | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/accounts.rs b/src/accounts.rs index 62724e03..81d002cd 100644 --- a/src/accounts.rs +++ b/src/accounts.rs @@ -316,16 +316,17 @@ impl AccountsGuard { account: &AccountName, _auth: Authorisation) { - let (accounts, oe) = if_chain! { + let (accounts, acctid) = if_chain! { if let Some(accounts) = self.0.as_mut(); - let entry = accounts.names.entry(account); - if let hash_map::Entry::Occupied(oe) = entry; - then { (accounts, oe) } - else { throw!(ME::AccountNotFound) } + if let Some(&acctid) = accounts.names.get(account); + then { (accounts, acctid) } + else { throw!(AccountNotFound) } }; - let acctid = *oe.key(); - process_all_players_for_account(acctid, InstanceGuard::player_remove)?; - oe.remove(); + process_all_players_for_account(acctid, |ig,player| { + ig.player_remove(player)?; + Ok::<_,ME>(()) + })?; + accounts.names.remove(account); accounts.records.remove(acctid); self.save_accounts_now()?; } -- 2.30.2