Skip to content

Latest commit

 

History

History
21 lines (14 loc) · 663 Bytes

const-and-static.md

File metadata and controls

21 lines (14 loc) · 663 Bytes

% const and static

There is a new edition of the book and this is an old link.

Constants are always immutable, and may only be set to a constant expression, not the result of a function call or any other value that could only be computed at runtime.

Global variables are called static in Rust.

const MAX_POINTS: u32 = 100_000;
static HELLO_WORLD: &str = "Hello, world!";

You can find the latest version about constants here, and about statics here.