Macro kernel::second_item
source · [−]macro_rules! second_item {
($(({$($first:tt)*}, $second:expr)),* $(,)?) => { ... };
($(($first:expr, $second:expr)),* $(,)?) => { ... };
}
Expand description
Converts a comma-separated list of pairs into an array with the second element. That is, it discards the first element of the pair.
Examples
assert_eq!([] as [u32; 0], second_item!());
assert_eq!([10u32], second_item!((X, 10u32)));
assert_eq!([10u32], second_item!((X, 10u32),));
assert_eq!([10u32], second_item!(({ X }, 10u32)));
assert_eq!([10u32], second_item!(({ X }, 10u32),));
assert_eq!([10u32, 20], second_item!((X, 10u32), (X, 20)));
assert_eq!([10u32, 20], second_item!((X, 10u32), (X, 20),));
assert_eq!([10u32, 20], second_item!(({ X }, 10u32), ({ X }, 20)));
assert_eq!([10u32, 20], second_item!(({ X }, 10u32), ({ X }, 20),));
assert_eq!([10u32, 20, 30], second_item!((X, 10u32), (X, 20), (X, 30)));
assert_eq!([10u32, 20, 30], second_item!((X, 10u32), (X, 20), (X, 30),));
assert_eq!([10u32, 20, 30], second_item!(({ X }, 10u32), ({ X }, 20), ({ X }, 30)));
assert_eq!([10u32, 20, 30], second_item!(({ X }, 10u32), ({ X }, 20), ({ X }, 30),));