Minor refactoring

Use "From<>" instead of "Into<>" for MainMenuMessage to GameState.
This commit is contained in:
Stephen Seo 2022-03-07 13:14:57 +09:00
parent 2e58bc1288
commit 5e2c5b6d41
2 changed files with 11 additions and 11 deletions

View file

@ -1,3 +1,4 @@
use crate::yew_components::MainMenuMessage;
use std::cell::Cell; use std::cell::Cell;
use std::fmt::Display; use std::fmt::Display;
use std::rc::Rc; use std::rc::Rc;
@ -17,6 +18,16 @@ impl Default for GameState {
} }
} }
impl From<MainMenuMessage> for GameState {
fn from(msg: MainMenuMessage) -> Self {
match msg {
MainMenuMessage::SinglePlayer => GameState::SinglePlayer,
MainMenuMessage::LocalMultiplayer => GameState::LocalMultiplayer,
MainMenuMessage::NetworkedMultiplayer => GameState::NetworkedMultiplayer,
}
}
}
#[derive(Copy, Clone, Debug, PartialEq, Eq)] #[derive(Copy, Clone, Debug, PartialEq, Eq)]
pub enum BoardState { pub enum BoardState {
Empty, Empty,

View file

@ -12,17 +12,6 @@ pub enum MainMenuMessage {
NetworkedMultiplayer, NetworkedMultiplayer,
} }
#[allow(clippy::from_over_into)]
impl Into<GameState> for MainMenuMessage {
fn into(self) -> GameState {
match self {
MainMenuMessage::SinglePlayer => GameState::SinglePlayer,
MainMenuMessage::LocalMultiplayer => GameState::LocalMultiplayer,
MainMenuMessage::NetworkedMultiplayer => GameState::NetworkedMultiplayer,
}
}
}
impl Component for MainMenu { impl Component for MainMenu {
type Message = MainMenuMessage; type Message = MainMenuMessage;
type Properties = (); type Properties = ();