Skip to main content

ordinal_map/ordinal/impls/
boxed.rs

1use crate::Ordinal;
2
3impl<T: Ordinal> Ordinal for Box<T> {
4    const ORDINAL_SIZE: usize = T::ORDINAL_SIZE;
5
6    fn ordinal(&self) -> usize {
7        (**self).ordinal()
8    }
9
10    fn from_ordinal(ordinal: usize) -> Option<Self> {
11        Some(Box::new(T::from_ordinal(ordinal)?))
12    }
13}
14
15#[cfg(test)]
16mod tests {
17    use crate::tests::util::test_ordinal;
18
19    #[test]
20    fn test_box() {
21        test_ordinal([Box::new(false), Box::new(true)])
22    }
23}