Generic constans are almost pattern synonyms

This is just a silly observation I made, but...

#![feature(generic_const_items)]

const SOME_INT_PAIR<const N: usize>: Option<(usize, usize)> = Some((N, N));

almost mirrors the semantics of

pattern SomeIntPair n = Just (n, n)

pattern synonyms

1 Like

This is because, like pattern aliases, rust constants can be used both in expressions and in patterns.

1 Like

consts can have generic parameters??

Notice the feature flag. The tracking issue is Tracking issue for generic const items · Issue #113521 · rust-lang/rust · GitHub

3 Likes