Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Adds support for implementing semigroup for types that can plus_equals from another type, for example vectors and slices. Fixes a bug where the semigroup implementation for `Vec` would add overhanging elements twice, i.e., `[1,2] + [1,1,1]` would result in `[2,3,2`] instead of `[2,3,1]`. This leaves one quirk where `is_zero` does not depend on `Rhs`, so Rust cannot figure out which implementation to use when two are in scope, forcing the caller to phrase it as `<R as Semigroup>::is_zero(&value)`. This only applies if `R` implements `Semigroup + Semigroup<Other>`. Signed-off-by: Moritz Hoffmann <[email protected]>
- Loading branch information