64 lines
1.1 KiB
Rust
64 lines
1.1 KiB
Rust
#[derive(Clone,Debug,Copy)]
|
|||
|
|
pub enum CellValue {
|
||
|
|
One,
|
||
|
|
Two,
|
||
|
|
Three,
|
||
|
|
Four,
|
||
|
|
Five,
|
||
|
|
Six,
|
||
|
|
Seven,
|
||
|
|
Eight,
|
||
|
|
Nine
|
||
|
|
}
|
||
|
|
|
||
|
|
pub struct Cell {
|
||
|
|
value: Option<CellValue>,
|
||
|
|
candidates: Vec<CellValue>,
|
||
|
|
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Default for Cell {
|
||
|
|
fn default() -> Cell {
|
||
|
|
Cell {
|
||
|
|
value : None,
|
||
|
|
candidates : vec![
|
||
|
|
CellValue::One,
|
||
|
|
CellValue::Two,
|
||
|
|
CellValue::Three,
|
||
|
|
CellValue::Four,
|
||
|
|
CellValue::Five,
|
||
|
|
CellValue::Six,
|
||
|
|
CellValue::Seven,
|
||
|
|
CellValue::Eight,
|
||
|
|
CellValue::Nine
|
||
|
|
]
|
||
|
|
}
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
#[derive(Default)]
|
||
|
|
pub struct Board {
|
||
|
|
cells: [ [ Cell ; 9 ] ; 9 ]
|
||
|
|
}
|
||
|
|
|
||
|
|
impl Board {
|
||
|
|
fn value(self, x: usize, y : usize) -> Option<CellValue> {
|
||
|
|
self.cells[x][y].value
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
pub fn add(left: u64, right: u64) -> u64 {
|
||
|
|
left + right
|
||
|
|
}
|
||
|
|
|
||
|
|
#[cfg(test)]
|
||
|
|
mod tests {
|
||
|
|
use super::*;
|
||
|
|
|
||
|
|
#[test]
|
||
|
|
fn it_works() {
|
||
|
|
let result = add(2, 2);
|
||
|
|
assert_eq!(result, 4);
|
||
|
|
}
|
||
|
|
}
|