Why are supertraits weird?

⚓ Rust    📅 2025-08-26    👤 surdeus    👁️ 4      

surdeus

Info

This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Why are supertraits weird?

Why does the first compile and the second not?

I have two traits and i want one to require the first. The first trait requires for the type to implement IntoIterator for &Self (not Self, so that i can use iter() or implement it later for all T that have that trait). But I have to specify again where for<'a> &'a Self: IntoIterator, in the second trait.
Since i have other traits that require the basic trait I dont want to clutter all the code with bounds that are required in some mod far from the actual code.

3 posts - 2 participants

Read full topic

🏷️ Rust_feed