Re:A half-hour to learn Rust
by GolDDranks on Saturday January 02, 2021 @01:40PM
(#25615160)
You seem to misunderstand what type : lifetime means.
> 'static in this context would mean that all members of T must be 'static, which means that all instances of T must be 'static.
Your "which means that" isn't true. It doesn't mean that. The syntax type : lifetime indicates that the values of the type MUST BE ABLE to outlive the lifetime. It doesn't mean that they NEED to outlive the lifetime.
This means, for example, i32 : 'static even in the case doesn't live the whole 'static lifetime. It COULD live, though, if the author of the code allocated it statically.
> 'static in this context would mean that all members of T must be 'static, which means that all instances of T must be 'static.
Your "which means that" isn't true. It doesn't mean that. The syntax type : lifetime indicates that the values of the type MUST BE ABLE to outlive the lifetime. It doesn't mean that they NEED to outlive the lifetime.
This means, for example, i32 : 'static even in the case doesn't live the whole 'static lifetime. It COULD live, though, if the author of the code allocated it statically.