lance_core/utils/
hash.rs

1// SPDX-License-Identifier: Apache-2.0
2// SPDX-FileCopyrightText: Copyright The Lance Authors
3
4use std::hash::Hasher;
5
6// A wrapper for &[u8] to allow &[u8] as hash keys,
7// the equality for this `U8SliceKey` means that the &[u8] contents are equal.
8#[derive(Eq)]
9pub struct U8SliceKey<'a>(pub &'a [u8]);
10impl PartialEq for U8SliceKey<'_> {
11    fn eq(&self, other: &Self) -> bool {
12        self.0 == other.0
13    }
14}
15
16impl std::hash::Hash for U8SliceKey<'_> {
17    fn hash<H: Hasher>(&self, state: &mut H) {
18        self.0.hash(state);
19    }
20}