devela/data/collections/array/d2/
impl_traits.rs#[cfg(feature = "alloc")]
use crate::Boxed;
use crate::{Array, Array2d, Bare, ConstDefault, Storage};
use core::fmt;
#[rustfmt::skip]
impl<T: Clone, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage>
Clone for Array2d<T, C, R, CR, RMAJ, S> where S::Stored<[T; CR]>: Clone {
fn clone(&self) -> Self {
Self { data: self.data.clone() }
}
}
#[rustfmt::skip]
impl<T: Copy, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage>
Copy for Array2d<T, C, R, CR, RMAJ, S> where S::Stored<[T; CR]>: Copy {}
#[rustfmt::skip]
impl<T: fmt::Debug, const C: usize, const R: usize, const CR: usize, S: Storage, const RMAJ: bool>
fmt::Debug for Array2d<T, C, R, CR, RMAJ, S> where S::Stored<[T; CR]>: fmt::Debug {
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
f.debug_struct("Array2d")
.field("T", &core::any::type_name::<T>())
.field("S", &S::name())
.field("C", &C).field("R", &R).field("CR", &CR).field("RMAJ", &RMAJ)
.field("data", &self.data)
.finish()
}
}
#[rustfmt::skip]
impl<T: PartialEq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage>
PartialEq for Array2d<T, C, R, CR, RMAJ, S> where S::Stored<[T; CR]>: PartialEq {
fn eq(&self, other: &Self) -> bool {
self.data == other.data && self.capacity() == other.capacity()
}
}
#[rustfmt::skip]
impl<T: Eq, const C: usize, const R: usize, const CR: usize, const RMAJ: bool, S: Storage>
Eq for Array2d<T, C, R, CR, RMAJ, S> where S::Stored<[T; CR]>: Eq {}
impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default
for Array2d<T, C, R, CR, RMAJ, Bare>
{
fn default() -> Self {
Self::panic_check_CR();
Self { data: Array::<T, CR, Bare>::default() }
}
}
impl<T: ConstDefault, const C: usize, const R: usize, const CR: usize, const RMAJ: bool>
ConstDefault for Array2d<T, C, R, CR, RMAJ, Bare>
{
const DEFAULT: Self = {
Self::panic_check_CR();
Self { data: Array::<T, CR, Bare>::DEFAULT }
};
}
#[cfg(feature = "alloc")]
#[cfg_attr(feature = "nightly_doc", doc(cfg(feature = "alloc")))]
impl<T: Default, const C: usize, const R: usize, const CR: usize, const RMAJ: bool> Default
for Array2d<T, C, R, CR, RMAJ, Boxed>
{
fn default() -> Self {
Self::panic_check_CR();
Self { data: Array::<T, CR, Boxed>::default() }
}
}