From: Ian Jackson Date: Sun, 31 Jan 2021 21:11:18 +0000 (+0000) Subject: hidden prep: api_wrest: Move was formatting earlier X-Git-Tag: otter-0.4.0~587 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=ceea1f6fb90b45f0619bdba3eae3e7cbd198f57d;p=otter.git hidden prep: api_wrest: Move was formatting earlier We want to drop the borrow on gs.players.get(was) because we will want a mut borrow of gs.players soon. NFC Signed-off-by: Ian Jackson --- diff --git a/daemon/api.rs b/daemon/api.rs index 4a3291f3..08dd25ce 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -256,14 +256,14 @@ api_route!{ let was = pc.held; pc.held = Some(player); let was = was.and_then(|p| gs.players.get(p)); + let was = was.map(|was| htmlescape::encode_minimal(&was.nick)); let update = PieceUpdateOp::Modify(()); let pls = &htmlescape::encode_minimal(&gpl.nick); let logent = LogEntry { html : Html(match was { - Some(was) => format!("{} wrested {} from {}", pls, pcs, - &htmlescape::encode_minimal(&was.nick)), + Some(was) => format!("{} wrested {} from {}", pls, pcs, was), None => format!("{} wrested {}", pls, pcs), })};