})().and_then(|(thunk, loose_conflict)| Ok((
match thunk {
OpOutcomeThunk::Immediate(r) => r,
- OpOutcomeThunk::Reborrow(f) => f(&mut ig, player, piece)?,
+ OpOutcomeThunk::Reborrow(f) => f(&mut ig, (player, piece))?,
}, loose_conflict
))) {
Err(APOE::Inapplicable(poe)) => {
let unprepared = match thunk {
Err(e) => Err(e),
Ok(OpHookThunk::Immediate(uu)) => Ok(uu),
- Ok(OpHookThunk::Reborrow(f)) => f(&mut ig, player),
+ Ok(OpHookThunk::Reborrow(f)) => f(&mut ig, (player,)),
};
if let Ok(unprepared) = unprepared.map_err(
|e| error!("internal error on change hook: {:?}", e));
take: MultigrabQty, new_z: ShouldSetZLevel) -> OpOutcomeThunk {
let currency = self.currency.clone();
OpOutcomeThunk::Reborrow(Box::new(
- move |ig: &mut InstanceGuard, player: PlayerId, tpiece: PieceId|
+ move |ig: &mut InstanceGuard, (player, tpiece)|
{
ig.fastsplit_split(player, tpiece, show, new_z,
move |_: &IOccults, _: &GameOccults, gpl: &GPlayer,
SetZLevelQuiet(ZL),
}
-#[derive(From)]
-pub enum OpOutcomeThunk {
- Immediate(UpdateFromOpComplex),
- /// Allows a UI operation full mutable access to the whole Instance.
- ///
- /// Use with care! Eg, you might have to call save_game_and_aux_later.
- ///
- /// Adding and removing pieces during play (rather than management)
- /// is complicated, because we want to avoid having to rewrite the aux.
- /// file during routine game saves. `fastsplit.rs` has machinery that
- /// can achieve this.
- Reborrow(Box<dyn FnOnce(&mut InstanceGuard, PlayerId, PieceId)
- -> Result<UpdateFromOpComplex, ApiPieceOpError>>),
-}
-
#[derive(From,Educe)]
-#[educe(Default)]
-pub enum OpHookThunk {
+#[educe(Default(bound="T: Default"))]
+pub enum OpOutcomeThunkGeneric<A,T,E> {
#[educe(Default)]
- Immediate(UnpreparedUpdates),
- /// Allows a UI operation full mutable access to the whole Instance.
+ Immediate(T),
+ /// Allows an operation full mutable access to the whole Instance.
///
- /// Use with care! Eg, you might have to call save_game_and_aux_late.r
+ /// Use with care! Eg, you might have to call save_game_and_aux_later.
///
/// Adding and removing pieces during play (rather than management)
/// is complicated, because we want to avoid having to rewrite the aux.
/// file during routine game saves. `fastsplit.rs` has machinery that
/// can achieve this.
- Reborrow(Box<dyn FnOnce(&mut InstanceGuard, PlayerId)
- -> Result<UnpreparedUpdates, InternalError>>),
+ Reborrow(Box<dyn FnOnce(&mut InstanceGuard, A) -> Result<T,E>>),
}
+pub type OpOutcomeThunk = OpOutcomeThunkGeneric<
+ (PlayerId, PieceId), UpdateFromOpComplex, ApiPieceOpError>;
+
+pub type OpHookThunk = OpOutcomeThunkGeneric<
+ (PlayerId,), UnpreparedUpdates, InternalError>;
+
pub type UpdateFromOpComplex = (
PieceUpdate,
UnpreparedUpdates,