sprs_rssn/
array_backend.rs

1//! Fixed size arrays usable for sparse matrices.
2//!
3//! Mainly useful to create a sparse matrix view over a sparse vector
4//! without allocation.
5
6use std::ops::{Deref, DerefMut};
7
8/// Wrapper around a size 2 array, with `Deref` implementation.
9#[derive(Debug, Copy, Clone)]
10pub struct Array2<T> {
11    pub data: [T; 2],
12}
13
14impl<T> Deref for Array2<T> {
15    type Target = [T];
16
17    fn deref(&self) -> &[T] {
18        &self.data[..]
19    }
20}
21
22impl<T> DerefMut for Array2<T> {
23    fn deref_mut(&mut self) -> &mut [T] {
24        &mut self.data[..]
25    }
26}