chiark / gitweb /
organise: Introduce PrimaryEnt (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 14:36:15 +0000 (15:36 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 3 Apr 2021 15:41:44 +0000 (16:41 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/organise.rs

index 91af5b6fdf8446fb27b71f365ca9b45520a33547..f7967486540958238173c90557089511356581e9 100644 (file)
@@ -80,9 +80,14 @@ impl Attempt {
   }
 }     
 
+struct PrimaryEnt {
+  piece: PieceId,
+  bbox: Rect,
+}
+
 #[throws(InternalError)]
 fn try_layout(region: &Rect,
-              pieces: &IndexVec<InHand, (PieceId, Rect)>,
+              pieces: &IndexVec<InHand, PrimaryEnt>,
               att: Attempt)
               -> Option<IndexVec<InHand, Pos>> {
   let mut out = default();
@@ -96,7 +101,7 @@ fn try_layout(region: &Rect,
   // Everything below n_y is overwriteable
   // Everything below and to the right of cur is overwriteable
 
-  for (piece, bbox) in pieces {
+  for PrimaryEnt { piece, bbox } in pieces {
     let place = 'placed: loop {
       for xi in 0..3 {
         let place = (cur - att.tl(&bbox)?)?;
@@ -166,7 +171,7 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str,
     if let Some(bbox) = want!( Ok = ipc.show(vis).bbox_approx(), ?piece );
     then {
       Some((
-        (piece, bbox),
+        PrimaryEnt { piece, bbox },
         gpc.zlevel.clone())
       )
     }
@@ -175,7 +180,7 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str,
     }
   }).unzip::<
     _,_,
-    IndexVec<InHand, (PieceId, Rect)>,
+    IndexVec<InHand, PrimaryEnt>,
     IndexVec<InHand, ZLevel>,
   >();
 
@@ -207,7 +212,9 @@ pub fn ui_operation(a: &mut ApiPieceOpArgs<'_>, opname: &str,
     let updates = {
       let mut updates = Vec::with_capacity(pieces.len());
 
-      for ((piece, _bbox), pos, zlevel) in izip!(pieces, layout, zlevels) {
+      for (PrimaryEnt { piece, .. }, pos, zlevel) in
+        izip!(pieces, layout, zlevels)
+      {
         want_let!{ Some(gpc) = gs.pieces.get_mut(piece); else continue; }
         gpc.pos = pos;
         gpc.zlevel = zlevel;