initial
This commit is contained in:
commit
071dcc25e0
5 changed files with 110 additions and 0 deletions
1
.gitignore
vendored
Normal file
1
.gitignore
vendored
Normal file
|
@ -0,0 +1 @@
|
|||
/target
|
7
Cargo.lock
generated
Normal file
7
Cargo.lock
generated
Normal file
|
@ -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"
|
8
Cargo.toml
Normal file
8
Cargo.toml
Normal file
|
@ -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]
|
0
a
Normal file
0
a
Normal file
94
src/main.rs
Normal file
94
src/main.rs
Normal file
|
@ -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
|
||||
}
|
||||
}
|
||||
)+
|
||||
};
|
||||
}
|
Loading…
Reference in a new issue