diff --git a/rs/src/board.rs b/rs/src/board.rs index ac590ed..f598d0c 100644 --- a/rs/src/board.rs +++ b/rs/src/board.rs @@ -47,10 +47,7 @@ impl Position { self.file.delta(delta_file)?, )) } - fn deltas_to_valid_positions( - &self, - deltas: &Vec<(i8, i8)>, - ) -> Vec { + fn deltas_to_valid_positions(&self, deltas: &[(i8, i8)]) -> Vec { deltas .iter() .filter_map(|&delta_rank_file| self.delta(delta_rank_file).ok()) @@ -89,9 +86,7 @@ where { const ALL_VALUES: [Self; 8]; fn new(index: u8) -> Result { - return Ok( - Self::ALL_VALUES[Self::validate_index(index)? as usize].clone() - ); + Ok(Self::ALL_VALUES[Self::validate_index(index)? as usize].clone()) } fn validate_index(index: u8) -> Result { if index as usize >= Self::ALL_VALUES.len() { @@ -194,14 +189,14 @@ impl Piece { fn _pawn_get_move_deltas(&self, position: &Position) -> Vec<(i8, i8)> { let direction = self.color.get_direction(); if position.rank == self.color.get_pawn_rank() { - vec![(1 * direction, 0), (2 * direction, 0)] + vec![(direction, 0), (2 * direction, 0)] } else { - vec![(1 * direction, 0)] + vec![(direction, 0)] } } fn _pawn_get_capture_deltas(&self) -> Vec<(i8, i8)> { let direction = self.color.get_direction(); - vec![(1 * direction, 1), (1 * direction, -1)] + vec![(direction, 1), (direction, -1)] } } @@ -211,7 +206,7 @@ pub struct Board { impl Board { pub fn get_at(&self, position: &Position) -> Option<&Piece> { - return self.state.get(position); + self.state.get(position) } pub fn set_at( &mut self,