mirror of https://github.com/rust-lang/nomicon
Currently, the lifetime elision doc only documents function definitions, but lifetime elision is also allowed in the following other locations: * `fn` types, such as `fn(&T)` * `Fn`/`FnMut`/`FnOnce`, such as `Fn(&T)` * `impl` headers To demo this up, I made some type aliases for `fn`/`Fn` which you can pass `&T` as a parameter to (to follow the lifetime rules of the surrounding context), and compared what you get with that instead of using `fn`/`Fn` directly, where lifetime elision takes on the rules from `fn`/`Fn`/etc. I also demoed up an `impl` header that used lifetime elision twice, although the error message in that case is broken (filed https://github.com/rust-lang/rust/issues/87763) The demo was half for this change description, and half just to make sure I understand Rust -- in particular, I really had to reverse engineer it for `impl` because I wasn't sure, and it didn't seem to be documented anywhere (at least not here!) https://play.rust-lang.org/?version=stable&mode=debug&edition=2018&gist=f82b280de4b992f225bc32121f333e96pull/298/head
parent
bf9b837b25
commit
3abf036ebf
Loading…
Reference in new issue