Const generic parameters

Hi all, I was trying to make a compile time list (with generics). I thought the best approach was to have a Head & Tail like enum (Value) and recursively match on the types. However I was unable to simply match on const generic parameters. Is there a plan to add this feature or is there another approach to fix this problem?

the type of const parameters must not depend on other generic parameters

enum Value<T> {
    Some(i32, T),
    None
}

fn get_value<T, const Val: Value<T>>() {
    match Val {
        Some(_, _) => {},
        None => {},
    }
}

Looks like you need const fn, not const generics

You cannot match on enum variants like that since they are not accessible. The correct syntax would be Value::Some(_, _)

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.