3 ms·
I'm a bit surprised this isn't covered in any of the documentation, but it might just be because the semantics are clear once you understand associated types. T
by smaddox 8y ago
I'm a bit surprised this isn't covered in any of the documentation, but it might just be because the semantics are clear once you understand associated types. The `Add` trait has an associated type `Output` that you must define when implementing `Add`. The semantics are then that the type on the left decides the output, but that type can change with the type on the right. It is up to the type author to provide appropriate symmetric implementations to avoid the confusion you describe.