doc_example/
doc_example.rs1use core::mem::size_of_val;
2use header_vec::HeaderVec;
3
4#[derive(Debug)]
5struct OurHeaderType {
6 #[allow(dead_code)]
7 a: usize,
8}
9
10fn main() {
11 let h = OurHeaderType { a: 2 };
12 let mut hv = HeaderVec::<OurHeaderType, char>::new(h);
13 hv.push('x');
14 hv.push('z');
15
16 println!(
17 "[`HeaderVec`] itself consists solely of a pointer, it's only {} bytes big.",
18 size_of_val(&hv)
19 );
20 println!(
21 "All of the data, like our header `{:?}`, the length of the vector: `{}`,",
22 &*hv,
23 hv.len()
24 );
25 println!(
26 "and the contents of the vector `{:?}` resides on the other side of the pointer.",
27 hv.as_slice()
28 );
29}