Minor refactoring
Use "From<>" instead of "Into<>" for MainMenuMessage to GameState.
This commit is contained in:
parent
2e58bc1288
commit
5e2c5b6d41
2 changed files with 11 additions and 11 deletions
|
@ -1,3 +1,4 @@
|
|||
use crate::yew_components::MainMenuMessage;
|
||||
use std::cell::Cell;
|
||||
use std::fmt::Display;
|
||||
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)]
|
||||
pub enum BoardState {
|
||||
Empty,
|
||||
|
|
|
@ -12,17 +12,6 @@ pub enum MainMenuMessage {
|
|||
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 {
|
||||
type Message = MainMenuMessage;
|
||||
type Properties = ();
|
||||
|
|
Loading…
Reference in a new issue