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>.
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 onRhs
, 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 ifR
implementsSemigroup + Semigroup<Other>
.