macro_rules! destruct_tuple {
($($field:ident),* in $tup:expr) => { ... };
}
Expand description
Allows destructuring tuples in const
contexts, regardless of items having drop glue.
This is mainly useful to allow generic functions to return tuples without being then stuck without a way to pull them back apart.
ยงExample
use const_util::*;
const fn pair_to_arr<T>(pair: (T, T)) -> [T; 2] {
destruct_tuple! { a, b in pair }
[a, b]
}
assert_eq!(
pair_to_arr((String::from("ABC"), String::new())),
["ABC", ""],
);