vector_core/
partition.rs

1use std::hash::Hash;
2
3/// Calculate partitions for an item
4///
5/// This trait allows us to express in the type system that for some `Item` we
6/// are able to calculate a `Key` that identifies that item.
7pub trait Partitioner {
8    type Item;
9    type Key: Clone + Eq + Hash;
10
11    /// Partition the `Item` by calculating its `Key`
12    ///
13    /// The resulting key should ideally be unique for an `Item` or arrived at
14    /// in such a way that if two distinct `Item` instances partition to the
15    /// same key they are mergeable if put into the same collection by this key.
16    fn partition(&self, item: &Self::Item) -> Self::Key;
17}