diff options
author | Kjetil Orbekk <kj@orbekk.com> | 2022-12-28 07:26:26 -0500 |
---|---|---|
committer | Kjetil Orbekk <kj@orbekk.com> | 2022-12-28 07:26:36 -0500 |
commit | 454864ec86ea3b7081bdb9e0a2f83d365d8e297e (patch) | |
tree | 65a0dcfc8bf2033137609e4d198f3ffde5b5eb4b /protocol/src/bridge_engine.rs | |
parent | de26af72d526c8a6154d65c5ab6ec3f94244e2ba (diff) |
Fix clippy errors
Diffstat (limited to 'protocol/src/bridge_engine.rs')
-rw-r--r-- | protocol/src/bridge_engine.rs | 36 |
1 files changed, 14 insertions, 22 deletions
diff --git a/protocol/src/bridge_engine.rs b/protocol/src/bridge_engine.rs index 7d69b82..a3aa12e 100644 --- a/protocol/src/bridge_engine.rs +++ b/protocol/src/bridge_engine.rs @@ -735,19 +735,11 @@ impl GameState { } pub fn is_bidding(&self) -> bool { - if let GameState::Bidding { .. } = self { - true - } else { - false - } + matches!(self, GameState::Bidding { .. }) } pub fn is_playing(&self) -> bool { - if let GameState::Play { .. } = self { - true - } else { - false - } + matches!(self, GameState::Play { .. }) } pub fn bidding(&self) -> Result<&BiddingState, anyhow::Error> { @@ -810,8 +802,8 @@ impl GameState { #[derive(PartialEq, Eq, Clone, Debug, Serialize, Deserialize)] pub struct GameResult; -impl Into<GameResult> for PlayResult { - fn into(self) -> GameResult { +impl From<PlayResult> for GameResult { + fn from(_val: PlayResult) -> GameResult { GameResult } } @@ -960,18 +952,18 @@ impl Default for TableState { } } -impl Into<TableState> for MoveResult<GameState, GameResult> { - fn into(self) -> TableState { - match self { +impl From<MoveResult<GameState, GameResult>> for TableState { + fn from(val: MoveResult<GameState, GameResult>) -> Self { + match val { MoveResult::Current(game) => TableState::Game(game), MoveResult::Next(result) => TableState::Result(result), } } } -impl Into<TableState> for GameState { - fn into(self) -> TableState { - TableState::Game(self) +impl From<GameState> for TableState { + fn from(val: GameState) -> Self { + TableState::Game(val) } } @@ -1175,7 +1167,7 @@ mod tests { } fn mkcards(s: &str) -> Vec<Card> { - s.split(" ").map(mkcard).collect() + s.split(' ').map(mkcard).collect() } fn example_deal() -> Deal { @@ -1220,7 +1212,7 @@ mod tests { let game_state = GameState::new(mini_deal(), Player::North); assert_eq!(game_state.deal(), &mini_deal()); assert_eq!(game_state.dealer(), Player::North); - assert_eq!(game_state.is_bidding(), true); + assert!(game_state.is_bidding()); info!("Start bidding with game state {game_state:#?}"); let raise = |s| Bid::Raise(Raise::from_str(s).unwrap()); @@ -1240,8 +1232,8 @@ mod tests { .current() .unwrap(); info!("Start playing with game state {game_state:#?}"); - assert_eq!(game_state.is_bidding(), false); - assert_eq!(game_state.is_playing(), true); + assert!(!game_state.is_bidding()); + assert!(game_state.is_playing()); } #[test] |