What does computed at runtime mean

we can't use any value computed at runtime for const keyword , so what does that mean

It means that it is computed when you run the program, and not when the program is compiled.

3 Likes

const values must be initialized at compile time, const does not mean immutable in the same way as C or C++. In fact, it's better to think of const as constexpr from C++. Normal let bindings are immutable by default (like const from C and C++).

8 Likes

so const keyword in rust does not need a unchanged value but needs a known value at compile-time

Exactly

1 Like

Thx krishnaSannasi :slight_smile:

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.