chiark / gitweb /
apitest: updatess: Expect to find the pieces we are updating
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 17:21:55 +0000 (18:21 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 17:22:36 +0000 (18:22 +0100)
Signed-off-by: Ian Jackson <ijackson@chiark.greenend.org.uk>
apitest/atmain.rs

index cdfe06b7b6c8771f5ec1ec69efee4749923f34cc..253c51a65877513b26c4facc4205da2e2ed21938 100644 (file)
@@ -416,15 +416,14 @@ pub fn update_update_pieces<PI:Idx>(
   }
 
   fn findp<'p, PI:Idx>(pieces: &'p mut Pieces<PI>, piece: &'_ str)
-               -> Option<&'p mut PieceInfo<JsV>> {
-    pieces.iter_mut().find(|p| p.id == piece)
+               -> &'p mut PieceInfo<JsV> {
+    pieces.iter_mut().find(|p| p.id == piece).unwrap()
   }
 
   let v = v.as_object().unwrap();
 
   if k == "Piece" {
     let p = findp(pieces, v["piece"].as_str().unwrap());
-    if_let!{ Some(p) = p; else return }
     let (op, d) = v["op"].as_object().unwrap().iter().next().unwrap();
 
     match op.as_str() {