Skip to content

Latest commit

 

History

History
27 lines (18 loc) · 826 Bytes

File metadata and controls

27 lines (18 loc) · 826 Bytes

Using const generics

Status: Stub

Complete const generics are currently unstable. You can track their progress here.

Const generics are ok to use in public APIs, so long as they fit in the min_const_generics subset.

See const evaluation for details on what is accepted for the implementation of const functions/contexts, which may not use const generics.

For reviewers

Look out for const operations on const generics in public APIs like:

pub fn extend_array<T, const N: usize, const M: usize>(arr: [T; N]) -> [T; N + 1] {
    ..
}

or for const generics that aren't integers, bools, or chars:

pub fn tag<const S: &'static str>() {
    ..
}