add tuple-apply macro with length argument for now
Signed-off-by: Jason Volk <jason@zemos.net>
This commit is contained in:
parent
1fbfc983e9
commit
ad117641b8
1 changed files with 27 additions and 0 deletions
|
@ -53,6 +53,25 @@ macro_rules! extract_variant {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! apply {
|
||||||
|
(1, $($idx:tt)+) => {
|
||||||
|
|t| (($($idx)+)(t.0),)
|
||||||
|
};
|
||||||
|
|
||||||
|
(2, $($idx:tt)+) => {
|
||||||
|
|t| (($($idx)+)(t.0), ($($idx)+)(t.1),)
|
||||||
|
};
|
||||||
|
|
||||||
|
(3, $($idx:tt)+) => {
|
||||||
|
|t| (($($idx)+)(t.0), ($($idx)+)(t.1), ($($idx)+)(t.2),)
|
||||||
|
};
|
||||||
|
|
||||||
|
(4, $($idx:tt)+) => {
|
||||||
|
|t| (($($idx)+)(t.0), ($($idx)+)(t.1), ($($idx)+)(t.2), ($($idx)+4)(t.3))
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! at {
|
macro_rules! at {
|
||||||
($idx:tt) => {
|
($idx:tt) => {
|
||||||
|
@ -112,6 +131,14 @@ macro_rules! is_not_empty {
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// Functor for equality i.e. (a, b).map(is_equal!())
|
||||||
|
#[macro_export]
|
||||||
|
macro_rules! is_equal {
|
||||||
|
() => {
|
||||||
|
|a, b| a == b
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
/// Functor for truthy
|
/// Functor for truthy
|
||||||
#[macro_export]
|
#[macro_export]
|
||||||
macro_rules! is_true {
|
macro_rules! is_true {
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue