maze/maze_solution.rs
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39
use crate::MazePath;
use serde::{Deserialize, Serialize};
use utoipa::ToSchema;
/// Represents a maze solution
#[derive(Debug, PartialEq, Serialize, Deserialize, ToSchema)]
pub struct MazeSolution {
/// Solution path
pub path: MazePath,
}
impl MazeSolution {
/// Creates a maze solution instance with the given solution path
/// # Arguments
/// * `path` - Solution path
///
/// # Returns
///
/// A new solution instance
///
/// # Examples
///
/// ```
/// use data_model::MazePoint;
/// use maze::{MazePath, MazeSolution};
/// let path = MazePath {
/// points: vec![
/// MazePoint { row: 0, col: 1 },
/// MazePoint { row: 0, col: 0 },
/// MazePoint { row: 1, col: 0 },
/// ],
/// };
/// let s = MazeSolution::new(path);
/// assert_eq!(s.path.points.len(), 3);
/// ```
pub fn new(path: MazePath) -> MazeSolution {
MazeSolution { path }
}
}