how do apis typically manage to actually « use » the « bar » of your example, such as storing it somewhere, without enforcing some kind of constraints ?
"BarTrait" is the constraint.
This is monomorphized for every type you pass in, in short.
If you need to store the value then you have no choice but to take in a dyn trait.
"BarTrait" is the constraint.
This is monomorphized for every type you pass in, in short.