luaur_common/methods/variant_cmax.rs
1use crate::records::variant::Variant1;
2
3impl<T0> Variant1<T0> {
4 pub const fn cmax(l: &[usize]) -> usize {
5 let mut res = 0;
6 let mut i = 0;
7 while i < l.len() {
8 let val = l[i];
9 if res < val {
10 res = val;
11 }
12 i += 1;
13 }
14 res
15 }
16}
17
18/// Helper for `VariantN` family to access the static `cmax` utility.
19/// In C++ this is a static member of the variadic `Variant` template.
20/// In Rust, we provide it on the base `Variant1` and can alias it if needed.
21#[allow(non_snake_case)]
22pub const fn variant_cmax(l: &[usize]) -> usize {
23 Variant1::<()>::cmax(l)
24}