dst/handle/
mod.rs

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
mod traits;
mod implementation;

/// This struct contains a value and the unsized-tail. It cannot be
/// normally instantiated.
pub struct Handle<V, T: ?Sized> {
    pub value: V,
    pub tail: T,
}

#[cfg(test)]
mod test {
    use super::*;

    #[test]
    fn size_check() {
        use std::mem::size_of;

        type T = (String, Vec<()>, Vec<usize>);
        for len in 0..4 {
            assert_eq!(
                size_of::<&str>() * len,
                Handle::<(), [&str]>::size_slice(len),
            );
            assert_eq!(
                size_of::<&str>() * len + size_of::<T>(),
                Handle::<T, [&str]>::size_slice(len),
            );
        }
    }
}