chiark / gitweb /
hidden: Have active_total_ppieces return usize
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2022 00:01:05 +0000 (01:01 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Mon, 25 Apr 2022 00:31:17 +0000 (01:31 +0100)
The fix for the un-notched pieces bug is going to want to add a
HashMap len to this, and that's usize.

Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/hidden.rs

index 967d5aa35c11f99e598ab214a4dcd4875b0e7e4d..26784e4e3fd799225d566149f835a6755bb9e8df 100644 (file)
@@ -142,10 +142,11 @@ impl PieceOccult {
 
   #[throws(IE)]
   pub fn active_total_ppieces(&self, goccults: &GameOccults)
-                              -> Option<NotchNumber> {
-    self.active_occ(goccults)?.map(
-      |occ| occ.notches.len()
-    )
+                              -> Option<usize> {
+    self.active_occ(goccults)?.map(|occ| {
+      let notches_len = usize::try_from(occ.notches.len()).unwrap();
+      notches_len
+    })
   }
 
   pub fn passive_occid(&self) -> Option<OccId> { Some(self.passive?.occid) }