this post was submitted on 17 Jun 2025
12 points (100.0% liked)
Rust
7129 readers
17 users here now
Welcome to the Rust community! This is a place to discuss about the Rust programming language.
Wormhole
Credits
- The icon is a modified version of the official rust logo (changing the colors to a gradient and black background)
founded 2 years ago
MODERATORS
you are viewing a single comment's thread
view the rest of the comments
view the rest of the comments
@capuccino
Then, when you write somewhere that some type satisfies a trait, like "T: Foo", and Foo has an associated type, you can further specify that not only does T need to implement Foo, but that the associated type satisfies some criteria.
You can do this two ways:
"Foo<Bar = Something>" says it has to be something specific,
"Foo<Bar: Baz>" says that it has to implement another trait
Amazing, so I can keep still using traits as constraints rather than types. I understand know. Hehehe, this is something that has been in my head since days ago