diff --git a/src/board.rs b/src/board.rs index 67d3ad0..675f1f0 100644 --- a/src/board.rs +++ b/src/board.rs @@ -234,14 +234,14 @@ impl Board { /// Return a modified [`Board`] with the piece placed at a position /// Returns None if the move was invalid - pub fn what_if(&self, i: usize, j: usize, piece: Piece) -> Option { + pub fn what_if(&self, i: usize, j: usize, piece: Piece) -> Result { // extract check here to avoid copy if self.get(i, j).is_some() { - return None; + return Err("position is occupied"); } let mut self_copy = *self; - self_copy.place(i, j, piece).ok().map(|_| self_copy) + self_copy.place(i, j, piece).map(|_| self_copy) } /// Returns a bool which represents whether or not a move would propegate and be valid