macro_rules! fold {
($($fold_args:tt)*) => { ... };
}Expand description
Folds an array into a single value in const contexts.
ยงExamples
use const_tools::{fold, destructure};
const fn last<T, const N: usize>(value: [T; N]) -> Option<T> {
fold!(value, None, |prev, item| {
std::mem::forget(prev); // Can't drop in const context, for the sake of illustration
Some(item)
})
}