4 ms·
https://doc.rust-lang.org/rust-by-example/scope/lifetime/static_lifetime.html#reference-lifetime https://doc.rust-lang.org/rust-by-example/scope/lifetime/sta...
by n3t 2y ago
https://doc.rust-lang.org/rust-by-example/scope/lifetime/static_lifetime.html#reference-lifetime https://doc.rust-lang.org/rust-by-example/scope/lifetime/sta... says:
> As a reference lifetime 'static indicates that the data pointed to by the reference lives for the remaining lifetime of the running program.
- tczMUFlmoNk 2y agoWhat your link says is correct about `&'static T`, a lifetime on a reference. What GP says is correct about `T: 'static`, a type constraint. They both use the "keyword" 'static, but in different senses.
- littlestymaar 2y agoYes, and IMHO this is one of the biggest design wart of Rust. T: 'unbounded would be much better.
- phamilton 2y ago`'unbounded` isn't a bad idea. With my team when someone new to Rust hits the static type constraint I usually tell them an overly simplified "is not a reference" followed up with "The data does not have any constraints (or bounds) on its lifetime that this code needs to worry about." I don't know if `unbounded` would immediately be understood by someone new to Rust, but it captures that `T: 'static` is a negating assertion. I.e. it largely says what it can't be.