Skip to content

Commit 5695609

Browse files
committed
update example to generate doc output
1 parent 7421ae6 commit 5695609

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

examples/doc_example.rs

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ use header_vec::HeaderVec;
33

44
#[derive(Debug)]
55
struct OurHeaderType {
6+
#[allow(dead_code)]
67
a: usize,
78
}
89

@@ -13,8 +14,16 @@ fn main() {
1314
hv.push('z');
1415

1516
println!(
16-
"HeaderVec itself consists solely of a pointer, it's only {} bytes big.",
17+
"[`HeaderVec`] itself consists solely of a pointer, it's only {} bytes big.",
1718
size_of_val(&hv)
1819
);
19-
println!("All of the data, like our header, {:?}, and the length of the vector: {}, resides on the other side of the pointer.", &*hv, hv.len());
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+
);
2029
}

src/lib.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,8 +37,9 @@ struct HeaderVecHeader<H> {
3737
/// hv.push('z');
3838
/// ```
3939
///
40-
/// [`HeaderVec`] itself consists solely of a pointer. It is the same size as a pointer to T.
41-
/// All of the data, like our header, `OurHeaderType { a: 2 }`, the length of the vector: `2`, and the contents of the vector `['x', 'z']` reside on the other side of the pointer.
40+
/// [`HeaderVec`] itself consists solely of a pointer, it's only 8 bytes big.
41+
/// All of the data, like our header `OurHeaderType { a: 2 }`, the length of the vector: `2`,
42+
/// and the contents of the vector `['x', 'z']` resides on the other side of the pointer.
4243
pub struct HeaderVec<H, T> {
4344
ptr: *mut T,
4445
_phantom: PhantomData<H>,

0 commit comments

Comments
 (0)