1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
use std::fmt::{Debug, Formatter, Result};

use crate::ImpVec;
use orx_pinned_vec::PinnedVec;

impl<T, P> Debug for ImpVec<T, P>
where
    P: PinnedVec<T>,
    T: Debug,
{
    fn fmt(&self, f: &mut Formatter<'_>) -> Result {
        self.cell.borrow().debug(f)
    }
}

#[cfg(test)]
mod tests {
    use crate::prelude::*;
    use crate::test_all_growth_types;
    use std::fmt::Debug;

    #[test]
    fn debug() {
        fn test<P: PinnedVec<usize> + Debug>(mut pinned_vec: P) {
            for i in 0..17 {
                pinned_vec.push(i);
            }
            let expected_debug = format!("{:?}", pinned_vec);

            let imp: ImpVec<_, _> = pinned_vec.into();
            assert_eq!(expected_debug, format!("{:?}", imp));
        }

        test_all_growth_types!(test);
    }
}