Skip to content
Free public beta until December 4, 2026: every course is open, no card needed. After that, the first chapter of each course stays free and full access is a one-time $39 ($19 for up to 100 founding members chosen for helpful feedback). Your progress is kept. How the beta works

const generics

Generics over a value, like an array's length, instead of a type.

A const generic parameter (const N: usize) makes an item generic over a compile-time constant, as in [T; N].

Examples

  • fn sum<const N: usize>(xs: [i32; N]) -> i32 accepts both [1, 2] and [1, 2, 3], with N inferred as 2 and 3.

Read the full section →