diff options
| author | Sam Anthony <sam@samanthony.xyz> | 2023-02-01 13:33:35 -0330 |
|---|---|---|
| committer | Sam Anthony <sam@samanthony.xyz> | 2023-02-01 13:33:35 -0330 |
| commit | 7587f9798bfd4c2d4cf17e673643727caa329548 (patch) | |
| tree | 951281ad01d108433dc93e9845efc9f19b598507 /src/lib.rs | |
| parent | ebf889219bbba702df0e7756c78268eb5437c30a (diff) | |
| download | pfc-7587f9798bfd4c2d4cf17e673643727caa329548.zip | |
input handling
Diffstat (limited to 'src/lib.rs')
| -rw-r--r-- | src/lib.rs | 21 |
1 files changed, 15 insertions, 6 deletions
@@ -1,13 +1,22 @@ pub mod ui; -enum Token { - Operand(f64), - Operator(Operator), -} - -enum Operator { +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); |