// Copyright 2025-2026 Gabriel Bjørnager Jensen.
//
// SPDX: MIT OR Apache-2.0

//! Operators for [`NVec`].

use core::ops::{Deref, DerefMut, Index, IndexMut};
use core::slice::SliceIndex;
use nvec::NVec;

impl<T, const N: usize> Deref for NVec<T, N> {
	type Target = [T];

	#[inline]
	fn deref(&self) -> &Self::Target {
		self.as_slice()
	}
}

impl<T, const N: usize> DerefMut for NVec<T, N> {
	#[inline]
	fn deref_mut(&mut self) -> &mut Self::Target {
		self.as_mut_slice()
	}
}

impl<T, I: SliceIndex<[T]>, const N: usize> Index<I> for NVec<T, N> {
	type Output = I::Output;

	#[inline]
	fn index(&self, index: I) -> &Self::Output {
		Index::index(self.as_slice(), index)
	}
}

impl<T, I: SliceIndex<[T]>, const N: usize> IndexMut<I> for NVec<T, N> {
	#[inline]
	fn index_mut(&mut self, index: I) -> &mut Self::Output {
		IndexMut::index_mut(self.as_mut_slice(), index)
	}
}
