Skip to content

Commit

Permalink
minor refactoring
Browse files Browse the repository at this point in the history
  • Loading branch information
mx00s committed Jan 23, 2022
1 parent 8a085e1 commit 36c7d7a
Showing 1 changed file with 4 additions and 10 deletions.
14 changes: 4 additions & 10 deletions examples/vending_machine.rs
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ impl CoinsAndChocolatesState for VendingMachine<CoinsAndChocolates> {
let result = VendingMachine {
state: CoinsAndChocolates {
coins: self.state.coins.increment(),
chocolates: self.state.chocolates,
..self.state
},
};
debug!(?result, "inserted coin");
Expand Down Expand Up @@ -125,8 +125,7 @@ impl CoinsAndChocolatesState for VendingMachine<CoinsAndChocolates> {
chocolates: self.state.chocolates,
},
};
let coins = self.state.coins;
debug!(?result, ?coins, "collected coins");
debug!(?result, coins = ?self.state.coins, "collected coins");
result
}
}
Expand All @@ -146,11 +145,7 @@ impl NoCoinsButChocolatesState for VendingMachine<NoCoinsButChocolates> {

#[instrument]
fn get_coins(self) -> VendingMachine<NoCoinsButChocolates> {
let result = VendingMachine {
state: NoCoinsButChocolates {
chocolates: self.state.chocolates,
},
};
let result = self;
debug!(?result, "collected 0 coins");
result
}
Expand Down Expand Up @@ -227,8 +222,7 @@ impl CoinsButNoChocolatesState for VendingMachine<CoinsButNoChocolates> {
let result = VendingMachine {
state: NoCoinsNorChocolates,
};
let coins = self.state.coins;
debug!(?result, ?coins, "collected coins");
debug!(?result, coins = ?self.state.coins, "collected coins");
result
}
}
Expand Down

0 comments on commit 36c7d7a

Please sign in to comment.