TimelyDataflow / differential-dataflow

An implementation of differential dataflow using timely dataflow on Rust.
MIT License
2.51k stars 182 forks source link

Semigroup generic over Rhs #493

Closed antiguru closed 1 month ago

antiguru commented 1 month ago

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>.