Refactor using Clippy nursery and unwrap_used
This commit is contained in:
22
src/game.rs
22
src/game.rs
@@ -4,25 +4,25 @@ use crate::{
|
||||
};
|
||||
use String as FenError;
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct Game {
|
||||
pub board: Board,
|
||||
pub state: State,
|
||||
}
|
||||
|
||||
impl Game {
|
||||
pub fn new() -> Game {
|
||||
Game {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
board: Board::new(),
|
||||
state: State::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn new_from_fen(fen: &str) -> Result<Game, FenError> {
|
||||
pub fn new_from_fen(fen: &str) -> Result<Self, FenError> {
|
||||
from_fen(fen)
|
||||
}
|
||||
|
||||
pub fn run(&self) {
|
||||
pub const fn run(&self) {
|
||||
Board::new();
|
||||
}
|
||||
}
|
||||
@@ -33,7 +33,7 @@ impl Default for Game {
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Debug, PartialEq)]
|
||||
#[derive(Debug, PartialEq, Eq)]
|
||||
pub struct State {
|
||||
side_to_move: Color,
|
||||
castling_ability: u8,
|
||||
@@ -43,8 +43,8 @@ pub struct State {
|
||||
}
|
||||
|
||||
impl State {
|
||||
pub fn new() -> State {
|
||||
State {
|
||||
pub const fn new() -> Self {
|
||||
Self {
|
||||
side_to_move: Color::White,
|
||||
castling_ability: 0b1111,
|
||||
en_passant_target_square: 0,
|
||||
@@ -53,14 +53,14 @@ impl State {
|
||||
}
|
||||
}
|
||||
|
||||
pub fn load_state(
|
||||
pub const fn load_state(
|
||||
side_to_move: Color,
|
||||
castling_ability: u8,
|
||||
en_passant_target_square: u8,
|
||||
halfmove_clock: u8,
|
||||
fullmove_counter: u8,
|
||||
) -> State {
|
||||
State {
|
||||
) -> Self {
|
||||
Self {
|
||||
side_to_move,
|
||||
castling_ability,
|
||||
en_passant_target_square,
|
||||
|
||||
Reference in New Issue
Block a user