pub trait Dimension {
const DIMENSION: usize;
const SPACE: bool;
#[inline]
fn get_default_separator() -> &'static str {
match (Self::DIMENSION, Self::SPACE) {
(1, true) => " ",
(1, false) => "",
(2, true | false) => "\n",
(0 | 3.., _) => {
unimplemented!(
"Default separator for dimension {} is not supported.",
Self::DIMENSION,
)
}
}
}
}
impl<T: Dimension + ?Sized> Dimension for &T {
const DIMENSION: usize = T::DIMENSION;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension + ?Sized> Dimension for &mut T {
const DIMENSION: usize = T::DIMENSION;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension + ?Sized> Dimension for Box<T> {
const DIMENSION: usize = T::DIMENSION;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension + ?Sized> Dimension for std::rc::Rc<T> {
const DIMENSION: usize = T::DIMENSION;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension + ?Sized> Dimension for std::sync::Arc<T> {
const DIMENSION: usize = T::DIMENSION;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for Vec<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for [T] {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension, const N: usize> Dimension for [T; N] {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for std::collections::BTreeSet<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for std::collections::HashSet<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for std::collections::VecDeque<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for std::collections::LinkedList<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}
impl<T: Dimension> Dimension for std::collections::BinaryHeap<T> {
const DIMENSION: usize = T::DIMENSION + 1;
const SPACE: bool = T::SPACE;
}