diskann-quantization 0.51.0

DiskANN is a fast approximate nearest neighbor search library for high dimensional data
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
/*
 * Copyright (c) Microsoft Corporation.
 * Licensed under the MIT license.
 */

use diskann_quantization::multi_vector::{Mat, MatMut, Standard};

// Test that `get_row` on MatMut correctly captures an immutable borrow,
// preventing mutation of the MatMut while the row is in scope.
fn main() {
    let mut mat: Mat<Standard<f32>> = Mat::new(Standard::new(4, 3).unwrap(), 0.0f32).unwrap();
    let mut view: MatMut<'_, Standard<f32>> = mat.as_view_mut();
    let row = view.get_row(0).unwrap();
    // This should fail: we cannot mutably borrow `view` while `row` exists
    let _ = view.get_row_mut(1);
    assert_eq!(row[0], 0.0);
}