3 ms·
I believe ‘static is assumed if there are no inputs.
by garmaine 6y ago
I believe ‘static is assumed if there are no inputs.
- Manishearth 6y agoNo, not quite, the signature will be `fn foo<'a>() -> &'a u8` (there is no way to elide this) However, Rust lifetimes are stretchy-squeezy, and a free lifetime is basically the same as 'static when it comes to covariant lifetimes, since both are "I can be whatever you want me to be". However if the lifetime is invariant (e.g. in https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=33cfb6dfde60bb44e36a71b461e66724 https://play.rust-lang.org/?version=stable&mode=debug&editio...), it is actually not 'static and will map to whatever lifetime is requested by the context.
- brundolf 6y agoWibbly-wobbly timey-wimey? :)
- josalhor 6y agoThat's not the case. Proof: https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=0fed983276f36448315d36ec48d0f823 https://play.rust-lang.org/?version=stable&mode=debug&editio...