chiark / gitweb /
clock: Break out State::reset (nfc)
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 16:53:25 +0000 (16:53 +0000)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 20 Mar 2021 21:42:32 +0000 (21:42 +0000)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
src/clock.rs

index c418ca0657be46a1b8df13595a2fad54389d720d..a924e536aecc9a5354433b14804d6bb28b7e979a 100644 (file)
@@ -109,6 +109,12 @@ impl State {
       current: None,
     }
   }
+
+  fn reset(&mut self, spec: &ChessClock) {
+    for ust in &mut self.users {
+      ust.remaining = spec.initial_time();
+    }
+  }
 }
 
 #[typetag::serde(name="ChessClock")]
@@ -438,9 +444,7 @@ impl PieceTrait for Clock {
         if state.current.is_some() {
           throw!(OE::BadPieceStateForOperation);
         }
-        for ust in &mut state.users {
-          ust.remaining = self.spec.initial_time();
-        }
+        state.reset(&self.spec);
         (Unpredictable, format!("reset"))
       },
       "claim-x" | "claim-y" => { // xxx these need to be Unpredictable