MCPcopy Create free account
hub / github.com/NodeDB-Lab/nodedb / hamming_distance

Function hamming_distance

nodedb-codec/src/vector_quant/hamming.rs:153–158  ·  view source on GitHub ↗
(a: &[u8], b: &[u8])

Source from the content-addressed store, hash-verified

151/// shorter length is used and the tail of the longer slice is ignored.
152#[inline]
153pub fn hamming_distance(a: &[u8], b: &[u8]) -> u32 {
154 debug_assert_eq!(a.len(), b.len(), "hamming_distance: slice length mismatch");
155 let len = a.len().min(b.len());
156 let f = DISPATCH.get_or_init(resolve);
157 f(&a[..len], &b[..len])
158}
159
160#[cfg(test)]
161mod tests {

Callers 3

Calls 1

lenMethod · 0.45

Tested by

no test coverage detected