docs

You are reading the docs for v0.1.2. Nabi 0.1.2 is no longer supported. Latest release: v0.1.3 →

#E0081: invalid const generic argument

A const generic argument has the wrong type or is out of range for its parameter. Pass a constant of the parameter's type.

nabi
struct Sep<const C: char> {}

let s = Sep::<97> {};
error[E0081]: const argument for `C: char` must be a `char`, found an integer
  --> main.nabi:3:9
   |
 3 | let s = Sep::<97> {};
   |         ^^^^^^^^^^^^

Pass a constant of the parameter's type:

nabi
struct Sep<const C: char> {}

let s = Sep::<'a'> {};
println("ok");
ok

A { .. } argument runs at compile time. When it panics, the error says so and carries the message (evaluating the const generic argument panicked: <message>): pass a value the const fn accepts, or a literal.

Related: E0082 wrong generic arguments, E0079 cannot evaluate at compile time

Found a mistake? Edit this page on GitHub. Last updated