From: Ian Jackson Date: Sun, 1 May 2022 10:13:36 +0000 (+0100) Subject: OpOutcomeThunk: change resolve to be method on thunk X-Git-Tag: otter-1.1.0~377 X-Git-Url: https://www.chiark.greenend.org.uk/ucgi/~ianmdlvl/git?a=commitdiff_plain;h=a30bc4e729b69182802d9c22e3be332d821df3f9;p=otter.git OpOutcomeThunk: change resolve to be method on thunk 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 --- diff --git a/daemon/api.rs b/daemon/api.rs index 0d3c05ed..fa76a0c9 100644 --- a/daemon/api.rs +++ b/daemon/api.rs @@ -196,7 +196,7 @@ fn api_piece_op(form: Json>) 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 { diff --git a/src/updates.rs b/src/updates.rs index b4974057..817db00c 100644 --- a/src/updates.rs +++ b/src/updates.rs @@ -380,13 +380,11 @@ impl StableIndexOffset for UpdateId { fn zero() -> Self { UpdateId(0) } } -#[ext(pub)] -impl Result,E> { - fn resolve(self, ig: &mut InstanceGuard, args: A) -> Result { +impl OpOutcomeThunkGeneric { + pub fn resolve(self, ig: &mut InstanceGuard, args: A) -> Result { 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), } } }