pub trait Capacity: Clone + Copy {
fn capacity(&self) -> usize;
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
pub struct ConstCap<const CAP: usize>;
impl<const CAP: usize> Capacity for ConstCap<CAP> {
#[inline]
fn capacity(&self) -> usize {
CAP
}
}
#[derive(Debug, PartialEq, Eq, PartialOrd, Ord, Clone, Copy, Hash)]
pub struct DynCap(pub(super) usize);
impl DynCap {
pub fn new(cap: usize) -> Self {
Self(cap)
}
}
impl Capacity for DynCap {
#[inline]
fn capacity(&self) -> usize {
self.0
}
}