Closed fmease closed 2 years ago
However, it appears that this user overlooked this sentence and did not read the lifetimes chapter. I strongly believe that this is not an uncommon situation: Users probably find this chapter by using a search engine after facing the
for<>
-syntax for the first time and getting to know it's called a HRTB or by reading the Nomicon nonlinearly/out of order.
"This user," here. Just wanted to say that this is exactly what happened. I was trying to understand the for<>
syntax after stumbling across it somewhere, and whatever it was that I Googled led me to that page in the 'nomicon as the first result.
thanks!
Recently, someone asked for some clarifications in the easy questions thread on the unofficial Rust subreddit regarding the HRTB chapter.
They were confused by the fact that they could not simply copy&paste the desugared and pseudo Rust code – with the modification
F: Fn(&'??? (u8, u16)) -> &'??? u8
→for<'a> F: Fn(&'a (u8, u16)) -> &'a u8
applied – into the playground and have it work out of the box.The pseudo Rust syntax is introduced in the lifetimes chapter (basically a simplified version of
-Z unpretty=hir
with lifetime annotations in expressions) as indeed mentioned above the HRTB code example. However, it appears that this user overlooked this sentence and did not read the lifetimes chapter. I strongly believe that this is not an uncommon situation: Users probably find this chapter by using a search engine after facing thefor<>
-syntax for the first time and getting to know it's called a HRTB or by reading the Nomicon nonlinearly/out of order. They merely skim the text and focus on the code examples without realizing one of them is not actual Rust code.To avoid future confusion, I
// NOTE
to the pseudo Rust code (simply mirroring the note in the lifetimes chapter)F
andfor<'a>
(not as relevant, just a general clarification)Feel free to provide improvements to my changes or to outright close this PR if you do not feel this is necessary/useful. I am aware this makes the chapter more verbose.