keyword

Rust static: define a program-lifetime static item

A static item has a program-lifetime storage location. An immutable static is useful for data shared across calls. Unlike a const item, a static denotes a particular allocation (subject to layout details). Expected output (not executed): ByteMind Why: The named static contains a reference to string-literal data. Common mistake: Do not use mutable statics as ordinary global counters; synchronization and aliasing requirements matter.

Formal Syntax & Structure

rust syntaxrust
static NAME: Type = expression;

Working Example

Example Snippetrust
static SITE_NAME: &str = "ByteMind";
fn main() {    println!("{SITE_NAME}");}
Rust Reference