Why Metada=() in Pointee<Metadata = ()> can be passed to Pointee Trait?

For a detailed description of the problem, please check this link

It's just a normal associated type bound, just like

fn take_iter<T>(iter: T)
    T: Iterator<Item = u64>,

which constrains the associated type to be the given type. In the case of Thin it's constraining Pointee::Metadata to be the unit type ().

I'm not really clear on what you're asking when you say "how it's passed"

I still don't understand how Metadata = () is passed to the Pointee trait, which does not contain the generic

Ahh, maybe you're confusing type parameters with associated types. When you pass a type parameter you don't use the Name = syntax, that's exclusively for associated types.

For example the Into trait has a type parameters specified by Into<u64>.

So Pointee<Metadata = ()> is constraining the type Metadata inside Pointee's declaration

Do you have any recommendations for information about type parameters and associated types?

The rust book has a section on associated types


Type parameters in traits work mostly the same way they do on structs and enums

This topic was automatically closed 90 days after the last reply. We invite you to open a new topic if you have further questions or comments.