Rust Constants

In this tutorial you will learn about the Rust Constants and its application with practical example.

Rust Constants

Constants are basically immutable literals whose values cannot be modified or changed during the execution of program. In Rust, constants live for the entire lifetime of a program and constants in Rust have no fixed address in memory.

Initializing Constants In Rust

The Constants are created in the same way you create variables but instead of using the let keyword here we use the const keyword and by convention constant names are always preferred in uppercase.

Syntax:-

or

Example:-

 

In this tutorial we have learn about the Rust Constants and its application with practical example. I hope you will like this tutorial.