diff options
author | visil <workregor@mail.ru> | 2023-11-20 00:37:09 +0300 |
---|---|---|
committer | visil <workregor@mail.ru> | 2023-11-20 00:37:09 +0300 |
commit | 0f496a8e5d2678ce3d81e402ab612534af787917 (patch) | |
tree | e98918dcae8d0226aeca2f6eedf9d69a8de5f5b6 /src/main.rs |
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()); +} |