Initial cell restrictions and url print.
This commit is contained in:
parent
338309fde6
commit
9901c6832f
6 changed files with 231 additions and 32 deletions
32
src/square.rs
Normal file
32
src/square.rs
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
use bitmaps::Bitmap;
|
||||
|
||||
#[derive(Clone, Debug)]
|
||||
pub enum Square {
|
||||
Value(u8),
|
||||
Options(Bitmap<9>),
|
||||
}
|
||||
|
||||
impl Square {
|
||||
pub fn from_char(c: char) -> Square {
|
||||
match c {
|
||||
'1' => Square::Value(1),
|
||||
'2' => Square::Value(2),
|
||||
'3' => Square::Value(3),
|
||||
'4' => Square::Value(4),
|
||||
'5' => Square::Value(5),
|
||||
'6' => Square::Value(6),
|
||||
'7' => Square::Value(7),
|
||||
'8' => Square::Value(8),
|
||||
'9' => Square::Value(9),
|
||||
'.' => Square::Options(Bitmap::mask(9)),
|
||||
_ => panic!("Unexpected character in input: {}", c),
|
||||
}
|
||||
}
|
||||
|
||||
pub fn to_str(&self) -> String {
|
||||
match self {
|
||||
Square::Options(_) => " ".to_string(),
|
||||
Square::Value(v) => v.to_string(),
|
||||
}
|
||||
}
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue