pub trait ACMap<S, V, H, W>:
Clone
+ ACMapBase
+ ACMapAddAssign<S, V, H, W>
+ ACMapMulAssign<V, H>
+ ACMapInsert<S, V, H, W>
+ ACMapContains<S, V, H, W>
+ ACMapScale<S, V, H, W>
+ ACMapRetain<S, V, H, W>
+ ACMapConsume{ }Expand description
Aggregate trait combining every operation a backing map must support
to be usable as the storage for a PauliSum.
You don’t normally implement ACMap directly: the blanket impl below
covers any type that implements all the constituent traits.
§Map-backend implementor’s guide
A new backing map (a GPU-resident map, a sharded map, anything beyond
the existing HashMap / IndexMap / AHashMap / DashMap backends)
needs these to satisfy the ACMap bound itself:
Clone.ACMapBase— construction, length, clear.ACMapAddAssign—+=insert-or-accumulate.ACMapMulAssign— scalar*=.ACMapInsert— justmap_insert_vecandmap_insert_multiple(there is no third variant to implement).ACMapContains— membership queries.ACMapScale— in-place per-entry transform.ACMapRetain— predicate-based entry removal.ACMapConsume— drain-and-accumulate merge of two maps.
Satisfying ACMap is necessary but not sufficient: ppvm-pauli-sum
bounds individual operations on further traits, so a backend that skips
them only fails to compile at those call sites. In practice you also
want:
ACMapIter— borrowing iteration over(key, value); needed byPauliSum::iter,Display, and the approximate-comparison helpers.Trace— needed byPauliSum::trace.Extend<(Word, Coeff)>— needed by the arithmetic operators.PartialEq— needed byPauliSum’s approximate comparisons.
Of these, map_insert_vec, map_insert_multiple, scale,
mul_assign, retain, and consume are whole-collection batch entry
points: a concurrent or GPU backend can dispatch each of them as one
parallel pass over every entry. add_assign is the exception — it
operates on a single key at a time, so a thread-pool backend typically
only parallelizes its batch sibling, map_add_assign. See the
DashMap impl in crates/ppvm-traits/src/map/dashmap.rs for a working
concurrent precedent: map_add_assign, mul_assign, map_insert_vec,
map_insert_multiple, scale, consume, and trace all go through
rayon par_iter. retain is the one that does not — its FnMut
predicate is not shareable across threads, so DashMap forwards to the
sequential DashMap::retain.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety".