Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: RPIT, confused by compiler error: "all type parameters are required to be mentioned in the precise captures list"
RPIT, confused by compiler error: "all type parameters are required to be mentioned in the precise captures list"
โ Rust ๐ 2025-08-07 ๐ค surdeus ๐๏ธ 4Hi everyone,
I am trying to write a method that returns an iterator, and I am hitting a compiler error that I donโt fully understand.
Here is a simplified version of the code:
use std::iter::once;
struct MyStruct;
impl MyStruct {
pub fn method<'s, 'a>(
&'s self,
a: impl Iterator<Item = &'a u128>,
) -> impl Iterator<Item = u128> + use<> {
once(0)
}
}
The compiler complains with this note:
note: currently, all type parameters are required to be mentioned in the precise captures list
But I donโt want to capture anything, thatโs the whole point for using use<>
in this case.
Rust playground link.
4 posts - 3 participants
๐ท๏ธ Rust_feed