mirror of
https://github.com/salsa-rs/salsa.git
synced 2025-01-23 05:07:27 +00:00
26 lines
496 B
Rust
26 lines
496 B
Rust
use std::ops::{Deref, DerefMut};
|
|
|
|
#[derive(Copy, Clone)]
|
|
pub struct Array<T, const N: usize> {
|
|
data: [T; N],
|
|
}
|
|
|
|
impl<T, const N: usize> Array<T, N> {
|
|
pub fn new(data: [T; N]) -> Self {
|
|
Self { data }
|
|
}
|
|
}
|
|
|
|
impl<T, const N: usize> Deref for Array<T, N> {
|
|
type Target = [T];
|
|
|
|
fn deref(&self) -> &Self::Target {
|
|
&self.data
|
|
}
|
|
}
|
|
|
|
impl<T, const N: usize> DerefMut for Array<T, N> {
|
|
fn deref_mut(&mut self) -> &mut Self::Target {
|
|
&mut self.data
|
|
}
|
|
}
|