Use const by default. Use static when you need a 'static reference or shared global state (e.g. static LOGGER: OnceLock<Logger>).


const: compile-time constant. Inlined at every use site. No fixed memory address.

const MAX: u32 = 100;

static: single instance with a fixed memory address for the program’s lifetime. Can be referenced (&'static).

static GREETING: &str = "hello";

static mut: mutable static — requires unsafe to access.


Key differences:

conststatic
Memory addressNo (inlined)Yes (one location)
'static referenceNoYes
MutableNoYes (unsafe)
Interior mutabilityNoYes (Mutex, OnceLock, etc.)