From 0f496a8e5d2678ce3d81e402ab612534af787917 Mon Sep 17 00:00:00 2001 From: visil Date: Mon, 20 Nov 2023 00:37:09 +0300 Subject: =?UTF-8?q?=D0=9D=D0=B0=D1=87=D0=B0=D0=BB=D1=8C=D0=BD=D1=8B=D0=B9?= =?UTF-8?q?=20=D0=BA=D0=BE=D0=BC=D0=BC=D0=B8=D1=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main.rs | 35 +++++++++++++++++++++++++++++++++++ 1 file changed, 35 insertions(+) create mode 100644 src/main.rs (limited to 'src/main.rs') 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 { + 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()); +} -- cgit v1.2.3