mirror of
https://github.com/Noratrieb/the-good-stuff.git
synced 2026-01-14 16:45:01 +01:00
int
This commit is contained in:
parent
785b3952b9
commit
153fb36814
2 changed files with 40 additions and 0 deletions
|
|
@ -1,6 +1,8 @@
|
||||||
#![feature(ptr_metadata)]
|
#![feature(ptr_metadata)]
|
||||||
|
#![feature(trace_macros)]
|
||||||
|
|
||||||
mod cfg_match;
|
mod cfg_match;
|
||||||
|
mod unroll_int;
|
||||||
mod unsized_clone;
|
mod unsized_clone;
|
||||||
|
|
||||||
pub use unsized_clone::*;
|
pub use unsized_clone::*;
|
||||||
|
|
|
||||||
38
src/unroll_int.rs
Normal file
38
src/unroll_int.rs
Normal file
|
|
@ -0,0 +1,38 @@
|
||||||
|
macro_rules! create_unroll_int {
|
||||||
|
// (_, 5) => 5
|
||||||
|
(replace@ ($a:tt, $($b:tt)*)) => { $($b)* };
|
||||||
|
|
||||||
|
// 2, 1, 0 => [0, 0, 0]
|
||||||
|
(turn_into_zero_array@ $($num:literal)*) => {
|
||||||
|
[$( create_unroll_int!(replace@ ($num, 0)) ),*]
|
||||||
|
};
|
||||||
|
|
||||||
|
($first:literal $($rest:literal)* | $($acc:tt)*) => {
|
||||||
|
create_unroll_int! {
|
||||||
|
$($rest)*
|
||||||
|
|
|
||||||
|
($first) => { create_unroll_int!(turn_into_zero_array@ $($rest)*) };
|
||||||
|
$($acc)*
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
(| $($acc:tt)*) => {
|
||||||
|
macro_rules! unroll_int {
|
||||||
|
$($acc)*
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
($($num:literal)*) => {
|
||||||
|
create_unroll_int! { $($num)* | }
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
create_unroll_int! {
|
||||||
|
// 20 19 18 17 16 15 14 13 12 11
|
||||||
|
//10 9 8 7 6 5 4 3
|
||||||
|
2 1 0
|
||||||
|
}
|
||||||
|
|
||||||
|
fn x() {
|
||||||
|
let x = unroll_int!(0);
|
||||||
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue