-
Notifications
You must be signed in to change notification settings - Fork 13k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a note about Higher-Ranked Trait Bounds in docs on Closures. #33611
Conversation
When using closures that take references with explicit lifetimes sometimes it's required to use where F: for<..> ... syntax to express the right lifetimes. This adds a quick note to the docs so other users can discover it as well.
Thanks for the pull request, and welcome! The Rust team is excited to review your changes, and you should hear from @steveklabnik (or someone else) soon. If any changes to this PR are deemed necessary, please add them as extra commits. This ensures that the reviewer can see what has changed since they last reviewed the code. Due to the way GitHub handles out-of-date commits, this should also make it reasonably obvious what issues have or haven't been addressed. Large or tricky changes may require several passes of review and changes. Please see the contribution instructions for more information. |
where F: for<'a> Fn(&'a 32) -> i32 { | ||
``` | ||
|
||
This lets the rust compiler find the minimum lifetime to invoke our closure and |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Rust, not rust
Thanks so much for this @vvanders ! I have one small grammar nit, and also, you need to add some annotations:
The examples get run as tests, so they don't work. Adding
Update it with that, and this should be good to go 👍 |
Thanks for the feedback and happy to help where I can. I'll see if I can address those and get an updated PR sent. |
Hey @steveklabnik, just wanted to check in here and make sure everything is good. Let me know if there's any further feedback or if you think this is okay to merge. |
@vvanders ah! Sorry about that. GitHub doesn't send a message when you push new commits; I didn't know you'd done so. |
@bors: r+ rollup |
📌 Commit 64feba0 has been approved by |
Add a note about Higher-Ranked Trait Bounds in docs on Closures. I hit a snag with lifetimes a few days ago and it wasn't until @birkenfeld pointed out Higher-Ranked Trait Bounds that I was able to solve the issue involving lifetimes on closure traits. This adds a small section in the book so that other users can find it. r? @steveklabnik
No worries, glad to have it merged :). |
I hit a snag with lifetimes a few days ago and it wasn't until @birkenfeld pointed out Higher-Ranked Trait Bounds that I was able to solve the issue involving lifetimes on closure traits. This adds a small section in the book so that other users can find it.
r? @steveklabnik