Static references versus static bounds
Quick answer
&'static T and T: 'static describe different things. The first is a reference valid for the entire program duration; the second limits what borrowed data a type may contain.
Reference duration versus type requirement
String literals have static lifetime. An owned String also satisfies a static type bound because it does not borrow non-static data, yet it may be dropped immediately. A static bound does not require the value to be stored forever or leaked.
fn label() -> &'static str { "ready" }fn main() { println!("{}", label()); }Expected stdout (not executed):
readyThe literal is valid independently of the call's scope.
fn consume<T: 'static>(value: T) { drop(value); }fn main() { consume(String::from("temporary")); println!("dropped");}Expected stdout (not executed):
droppedThe owned String satisfies the bound and is then released.
Common mistake
Do not add 'static to a borrowed parameter merely to silence a lifetime error.
Try it yourself
Try passing a reference to a local String into consume and explain why it fails.
Static examples for Rust 1.85.0, edition 2024. Run them locally in a disposable project; ByteMind execution support and these outputs have not been verified.
Check Your Understanding
Solidify your learning with the interactive assessment directly below this lesson.
Concept Quiz & Questions
Static references versus static bounds — practice quiz
Choose one answer per question, then review the explanation.
Which expression naturally has type `&'static str`?
Does `T: 'static` prohibit dropping a value of T?
Can a reference to a short-lived local generally satisfy `&'static str`?