Global Constants


Why does the following line doesn’t work?

const VAR :i32 = 2.pow(10);

It throws an error " no method named pow found for type _ in the current scope".


The reason you get that particular error is because rust doesn’t implicitly type integer constants. If you add an explicit type, then you get past that error:

const VAR :i32 = 2i32.pow(10);

though then you run into

 method calls in constants are limited to constant inherent methods [E0378]

since rust is very limited with respect to constants today.


Thanks for the response @tupshin.