diff options
Diffstat (limited to 'src/main.rs')
-rw-r--r-- | src/main.rs | 35 |
1 files changed, 35 insertions, 0 deletions
diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..d4e9cac --- /dev/null +++ b/src/main.rs @@ -0,0 +1,35 @@ + + +#[derive(Debug)] +enum BaseNumber { + Decimal(i64), + Octal(i64), + Binary(i64), + Hexadecimal(i64), + Nan, +} + +impl BaseNumber { + fn format(&self) -> Result<String, String> { + match self { + Self::Binary(value) => Ok(format!("{:b}", value)), + Self::Octal(value) => Ok(format!("{:o}", value)), + Self::Decimal(value) => Ok(format!("{}", value)), + Self::Hexadecimal(value) => Ok(format!("{:x}", value)), + Nan => Err("Not a number!".to_string()), + } + } +} + +#[derive(Debug)] +enum Operator { + Add, + Sub, + Mul, + Div, +} + +fn main() { + println!("Hello, world!"); + println!("{}", numformat(15, 16).unwrap()); +} |