From 82f8ab300b6c102310bcaae8ab0982fadcbbb302 Mon Sep 17 00:00:00 2001 From: Ian Jackson Date: Sun, 14 Mar 2021 19:12:06 +0000 Subject: [PATCH] Refactor: Break out pri.map_piece_update_op Signed-off-by: Ian Jackson --- src/pcrender.rs | 17 +++++++++++++++++ src/updates.rs | 10 +--------- 2 files changed, 18 insertions(+), 9 deletions(-) diff --git a/src/pcrender.rs b/src/pcrender.rs index e1f8301d..6cbb015f 100644 --- a/src/pcrender.rs +++ b/src/pcrender.rs @@ -35,6 +35,23 @@ impl VisiblePieceAngle { } impl PieceRenderInstructions { + #[throws(IE)] + pub fn map_piece_update_op(&self, ioccults: &IOccults, + gpc: &GPiece, ipc: &IPiece, + op: PieceUpdateOp<(),()> + ) -> PieceUpdateOp + { + op.try_map( + |()|{ + let ns = self.prep_piecestate(ioccults, gpc, ipc)?; + >::Ok(ns) + }, + |()|{ + Ok(gpc.zlevel.clone()) + } + )? + } + #[throws(IE)] pub fn prep_piecestate(&self, ioccults: &IOccults, gpc: &GPiece, ipc: &IPiece) diff --git a/src/updates.rs b/src/updates.rs index 16233ce9..b6eb9013 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -506,15 +506,7 @@ impl<'r> PrepareUpdatesBuffer<'r> { max_z.update_max(&gpc.zlevel.z); - let op = op.try_map( - |()|{ - let ns = pri.prep_piecestate(ioccults, gpc, ipc)?; - >::Ok(ns) - }, - |()|{ - Ok(gpc.zlevel.clone()) - } - )?; + let op = pri.map_piece_update_op(ioccults, gpc, ipc, op)?; Some(PreparedPieceUpdate { piece: pri.vpid, -- 2.30.2