RPIT, confused by compiler error: "all type parameters are required to be mentioned in the precise captures list"

โš“ Rust    ๐Ÿ“… 2025-08-07    ๐Ÿ‘ค surdeus    ๐Ÿ‘๏ธ 4      

surdeus

Hi 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

Read full topic

๐Ÿท๏ธ Rust_feed