From 071dcc25e04c62abbf1b980d8ceae48f0cebd230 Mon Sep 17 00:00:00 2001 From: mehbark Date: Sat, 10 Sep 2022 19:45:08 -0400 Subject: [PATCH] initial --- .gitignore | 1 + Cargo.lock | 7 ++++ Cargo.toml | 8 +++++ a | 0 src/main.rs | 94 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 5 files changed, 110 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 a create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..75c1544 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 3 + +[[package]] +name = "illion" +version = "0.1.0" diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..4d29721 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,8 @@ +[package] +name = "illion" +version = "0.1.0" +edition = "2021" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] diff --git a/a b/a new file mode 100644 index 0000000..e69de29 diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..7cd310b --- /dev/null +++ b/src/main.rs @@ -0,0 +1,94 @@ +fn main() { + println!("Hello, world!"); +} + +pub trait Illion: Sized { + #[must_use] + fn ten(self) -> Self; + illion! { + hundred 2 + thousand 3 + million 6 + billion 9 + trillion 12 + quadrillion 15 + quintillion 18 + sextillion 21 + septillion 24 + octillion 27 + nonillion 30 + decillion 33 + undecillion 36 + duodecillion 39 + tredecillion 42 + quattuordecillion 45 + quindecillion 48 + sexdecillion 51 + septemdecillion 54 + octodecillion 57 + novemdecillion 60 + vigintillion 63 + unvigintillion 66 + duovigintillion 69 + trevigintillion 72 + quattuorvigintillion 75 + quinvigintillion 78 + sexvigintillion 81 + septvigintillion 84 + octovigintillion 87 + nonvigintillion 90 + trigintillion 93 + untrigintillion 96 + duotrigintillion 99 + } +} + +// A lot of these make zero sense lol +illion_impl! { + // Unsigned integers + u8: 10 + u16: 10 + u32: 10 + u64: 10 + u128: 10 + usize: 10 + // Signed integers + i8: 10 + i16: 10 + i32: 10 + i64: 10 + i128: 10 + isize: 10 + // Floats + f32: 10.0 + f64: 10.0 +} + +#[macro_export] +macro_rules! illion { + ($( $name:ident $pow:expr ) +) => { + $( + #[must_use] + fn $name(self) -> Self { + let mut result = self; + for _ in 0..$pow { + result = result.ten(); + } + result + } + )+ + }; +} + +#[macro_export] +macro_rules! illion_impl { + ($( $type:ty : $ten:expr ) +) => { + $( + impl Illion for $type { + fn ten(self) -> Self { + self * $ten + } + } + )+ + }; +}