aboutsummaryrefslogtreecommitdiffstats
path: root/src/lib.rs
blob: e08796d46ddf9e048241f50df24b5bceda7497d9 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
pub mod ui;

pub enum Operator {
    Add,
    Sub,
    Mul,
    Div,
}

impl Operator {
    pub fn parse(c: char) -> Result<Self, ParseOperatorError> {
        match c {
            '+' => Ok(Self::Add),
            '-' => Ok(Self::Sub),
            '*' => Ok(Self::Mul),
            '/' => Ok(Self::Div),
            _ => Err(ParseOperatorError(c)),
        }
    }
}

pub struct ParseOperatorError(char);