3 ms·
Inferred lifetimes? A man can hope :).
by OoooooooO 9y ago
Inferred lifetimes? A man can hope :).
- steveklabnik 9y agoIf it were always possible to infer all lifetimes, we'd do it. Unfortunately that's not the case. There are a number of RFCs in the pipeline to help with lifetimes, including more elision. In no particular order: https://github.com/rust-lang/rfcs/pull/2115 https://github.com/rust-lang/rfcs/pull/2115 https://github.com/rust-lang/rfcs/pull/2094 https://github.com/rust-lang/rfcs/pull/2094 https://github.com/rust-lang/rfcs/pull/2093 https://github.com/rust-lang/rfcs/pull/2093
- dbaupp 9y agoInferring lifetimes from the implementation of a function won't happen for the same reason that inferring types won't happen: it is really nice for the signature of a function to not automatically be changed if the body is changed, instead programmers should be told when they might be breaking their users. However, the compiler could (and did, I believe) run inference and suggest a fix that the programmer can explicitly include.