From: Ian Jackson Date: Sat, 31 Oct 2020 12:52:48 +0000 (+0000) Subject: wip new accounts X-Git-Tag: otter-0.2.0~577 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=44f25d73b8f898e18aa7bcbee3bb87b2104d1f01;p=otter.git wip new accounts Signed-off-by: Ian Jackson --- 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()?; }