Randomize the deck of tiles
This commit is contained in:
@@ -1,15 +1,16 @@
|
||||
use enum_map::Enum;
|
||||
use std::fmt;
|
||||
|
||||
/// A single digit that can be wrapped in parentheses.
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
pub struct Digit {
|
||||
pub value: u8,
|
||||
pub value: i8,
|
||||
pub has_left_parenthesis: bool,
|
||||
pub has_right_parenthesis: bool,
|
||||
}
|
||||
|
||||
impl Digit {
|
||||
pub fn new(value: u8) -> Self {
|
||||
pub fn new(value: i8) -> Self {
|
||||
Self {
|
||||
value,
|
||||
has_left_parenthesis: false,
|
||||
@@ -44,9 +45,9 @@ impl TryFrom<&str> for Digit {
|
||||
let c = it.next().ok_or(())?;
|
||||
if c == '(' {
|
||||
res.has_left_parenthesis = true;
|
||||
res.value = it.next().ok_or(())?.to_digit(10).ok_or(())? as u8;
|
||||
res.value = it.next().ok_or(())?.to_digit(10).ok_or(())? as i8;
|
||||
} else {
|
||||
res.value = c.to_digit(10).ok_or(())? as u8;
|
||||
res.value = c.to_digit(10).ok_or(())? as i8;
|
||||
}
|
||||
if let Some(c) = it.next() {
|
||||
if c != ')' {
|
||||
@@ -59,7 +60,7 @@ impl TryFrom<&str> for Digit {
|
||||
}
|
||||
|
||||
/// An operator that can be applied between two terms.
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone)]
|
||||
#[derive(Debug, PartialEq, Eq, Copy, Clone, Enum)]
|
||||
pub enum Operator {
|
||||
Add,
|
||||
Subtract,
|
||||
|
Reference in New Issue
Block a user