I was reading the hyperium/http source code and I found this:
pub fn put<T>(uri: T) -> Builder
<Uri as TryFrom<T>>::Error: Into<crate::Error>,
In this snippet,
Uri is a type and
T a generic element.
I have always seen the construction
where T: SomeTrait, but not
Does this construction have a name and is it documented somewhere?
It's exactly the same construct.
Type: Trait is still a "trait bound", and it still means that
Type has an implementation of
Trait, no matter how complicated the type or trait expressions happen to be.
It's not a different construct, in one case you have a generic parameter, in another a concrete type, but they are both still types. Trait bounds can be applied to any type.
Amazing and fast answers. Thanks !
This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.