The compiler suggested that I add + use<'_, N>
in my code. The suggestion seems to have worked.
I'm struggling to find documentation on use<...>
The compiler suggested that I add + use<'_, N>
in my code. The suggestion seems to have worked.
I'm struggling to find documentation on use<...>
The use-bound was added to allow types hidden behind a return-position impl Trait
to capture (use) the generic parameters from its scope. The introductory blog post about this feature is quite extensive and has links to more material (RFC, tracking issues) at the end:
If you tell us where you looked for it and didn’t find it, we might be able to make the documentation more complete.
Rust "use<...>"
and numerous variations on the theme. Usually this is all that is needed. (This one is difficult to fix manually I'll fix that: Add the concrete syntax for precise capturing to 1.82 release notes. by kpreid · Pull Request #135542 · rust-lang/rust · GitHub
Apparently this is waiting for the 2024 edition to be stable (because when to use precise capturing is closely tied to the new edition).
By the way, another way to learn about keywords is to look them up in the standard library rustdoc! That will take you to the page for use which includes an explanation of precise capturing syntax.
Another place to look, for things that aren't in the Rust book, is the Rust reference. Searching it for "use" brings up something on use bounds as the sixth result for me (below 4 results on use declarations and one on the #[used]
attribute). The section on use bounds is fairly brief, but it links to precise capturing, which has more explanation.
I did actually land on that page, but saw a screenful talking about the usage of use
for importing, and concluded (too hastily) that this wasn't what I was looking for.