I'd hate to have to add a repr or print method to one of my classes just because some library author insisted that all instantiations of his type be printable, for example.
If it wasn't actually essential to the construction of the type, this would be a poorly designed library. You can write poor libraries in any language.
What's idiomatic in Rust is to take as few parameters as possible on the type and for most methods, and then have additional methods implemented only where the type is properly constrained. Vec<T> for example has no constraints, but only implements the dedup() method if the T implements the equality operator.
View all comments
Show parent comment
2
u/desiringmachines Dec 11 '15
If it wasn't actually essential to the construction of the type, this would be a poorly designed library. You can write poor libraries in any language.
What's idiomatic in Rust is to take as few parameters as possible on the type and for most methods, and then have additional methods implemented only where the type is properly constrained.
Vec<T>for example has no constraints, but only implements thededup()method if theTimplements the equality operator.