chiark / gitweb /
OpOutcomeThunk: change resolve to be method on thunk
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 10:13:36 +0000 (11:13 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sun, 1 May 2022 10:13:36 +0000 (11:13 +0100)
The other call site (which will come in a moment) doesn't have a
Result.  And this was a bit too cooked anyway.

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

index 0d3c05eddfc1063f148c54a947552fe80ac2678f..fa76a0c9fc8e66e3098407027688b5c1763487a6 100644 (file)
@@ -196,7 +196,7 @@ fn api_piece_op<O: op::Complex>(form: Json<ApiPiece<O>>)
       piece,
       was_held,
     );
-    let unprepared = thunk.resolve(&mut ig, (player,));
+    let unprepared = thunk.and_then(|t| t.resolve(&mut ig, (player,)));
     if let Ok(unprepared) = unprepared.map_err(
       |e| error!("internal error on change hook: {:?}", e));
     then {
index b49740574c51b50dec45b950c225a33d9f882637..817db00c013a93ee7d41265a7d749023989fcc08 100644 (file)
@@ -380,13 +380,11 @@ impl StableIndexOffset for UpdateId {
   fn zero() -> Self { UpdateId(0) }
 }
 
-#[ext(pub)]
-impl<A,T,E> Result<OpOutcomeThunkGeneric<A,T,E>,E> {
-  fn resolve(self, ig: &mut InstanceGuard, args: A) -> Result<T,E> {
+impl<A,T,E> OpOutcomeThunkGeneric<A,T,E> {
+  pub fn resolve(self, ig: &mut InstanceGuard, args: A) -> Result<T,E> {
     match self {
-      Err(e) => Err(e),
-      Ok(OOTG::Immediate(uu)) => Ok(uu),
-      Ok(OOTG::Reborrow(f)) => f(ig, args),
+      OOTG::Immediate(uu) => Ok(uu),
+      OOTG::Reborrow(f) => f(ig, args),
     }
   }
 }