# Error code E0435

A non-constant value was used in a constant expression.

Erroneous code example:

ⓘ

    let foo = 42;
    let a: [u8; foo]; // error: attempt to use a non-constant value in a constant

Run

‘constant’ means ‘a compile-time value’.

More details can be found in the Variables and Mutability section of the book.

To fix this error, please replace the value with a constant. Example:

    let a: [u8; 42]; // ok!

Run

Or:

    const FOO: usize = 42;
    let a: [u8; FOO]; // ok!

Run

Back to list of error codes