fractional-scale: implement accurate rounding
This commit is contained in:
parent
cc426a0a4a
commit
e2806a6337
5 changed files with 41 additions and 14 deletions
28
src/utils/array_to_tuple.rs
Normal file
28
src/utils/array_to_tuple.rs
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
pub trait ArrayToTuple {
|
||||
type Tuple;
|
||||
|
||||
fn to_tuple(self) -> Self::Tuple;
|
||||
}
|
||||
|
||||
macro_rules! ignore {
|
||||
($t:tt) => {
|
||||
T
|
||||
};
|
||||
}
|
||||
|
||||
macro_rules! array_to_tuple {
|
||||
($n:expr, $($field:ident,)*) => {
|
||||
impl<T> ArrayToTuple for [T; $n] {
|
||||
type Tuple = ($(ignore!($field),)*);
|
||||
|
||||
fn to_tuple(self) -> Self::Tuple {
|
||||
let [$($field,)*] = self;
|
||||
#[allow(clippy::allow_attributes)]
|
||||
#[allow(clippy::unused_unit)]
|
||||
($($field,)*)
|
||||
}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
array_to_tuple!(2, t1, t2,);
|
||||
Loading…
Add table
Add a link
Reference in a new issue