From 29668ab8ef19edc14893967479655d57fb4314ea Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Tue, 23 Mar 2021 22:53:01 +0000 Subject: [PATCH] hand: Move owned to where we can reuse it Signed-off-by: Ian Jackson --- src/hand.rs | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/src/hand.rs b/src/hand.rs index 07d5e8bf..0808a505 100644 --- a/src/hand.rs +++ b/src/hand.rs @@ -88,12 +88,15 @@ impl PieceTrait for Hand { fn nfaces(&self) -> RawFaceId { 1 } #[throws(IE)] fn svg_piece(&self, f: &mut Html, gpc: &GPiece, _gs: &GameState, _vpid: VisiblePieceId) { + let owned = if_chain!{ + if let Some(xdata) = gpc.xdata.get::()?; + if let Some(owned) = &xdata.owner; + then { Some(owned) } + else { None } + }; self.shape.svg_piece_raw(f, gpc.face, &mut |f: &mut String| { - if_chain!{ - if let Some(xdata) = gpc.xdata.get::()?; - if let Some(owned) = &xdata.owner; - then { write!(f, r##" stroke-dasharray="{}" "##, - &owned.dasharray.0)?; } + if let Some(owned) = owned { + write!(f, r##" stroke-dasharray="{}" "##, &owned.dasharray.0)?; } Ok(()) })?; -- 2.30.2