Skip to content

Commit

Permalink
Merge branch 'rust-cv:main' into main
Browse files Browse the repository at this point in the history
  • Loading branch information
cehteh authored Sep 17, 2024
2 parents d44385d + ff10458 commit 2076db3
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
[package]
name = "header-vec"
version = "0.1.3-alpha.0"
version = "0.1.3"
authors = ["Geordon Worley <[email protected]>"]
edition = "2018"
edition = "2021"
description = "Vector with user-specified header, length, capacity, and array elements all stored on the heap together"
documentation = "https://docs.rs/header-vec/"
repository = "https://github.com/rust-cv/header-vec"
Expand Down
13 changes: 11 additions & 2 deletions examples/doc_example.rs
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ use header_vec::HeaderVec;

#[derive(Debug)]
struct OurHeaderType {
#[allow(dead_code)]
a: usize,
}

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

println!(
"HeaderVec itself consists solely of a pointer, it's only {} bytes big.",
"[`HeaderVec`] itself consists solely of a pointer, it's only {} bytes big.",
size_of_val(&hv)
);
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());
println!(
"All of the data, like our header `{:?}`, the length of the vector: `{}`,",
&*hv,
hv.len()
);
println!(
"and the contents of the vector `{:?}` resides on the other side of the pointer.",
hv.as_slice()
);
}
12 changes: 4 additions & 8 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ struct HeaderVecHeader<H> {
len: AtomicUsize,
}

/// A vector with a header of your choosing, behind a thin pointer
/// A vector with a header of your choosing behind a thin pointer
///
/// # Example
///
Expand All @@ -36,15 +36,11 @@ struct HeaderVecHeader<H> {
/// let mut hv = HeaderVec::<OurHeaderType, char>::new(h);
/// hv.push('x');
/// hv.push('z');
///
/// println!("HeaderVec itself consists solely of a pointer, it's only {} bytes big.", size_of_val(&hv));
/// 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());
/// ```
///
/// ```ignore
/// HeaderVec itself consists solely of a pointer, it's only 8 bytes big.
/// All of the data, like our header, OurHeaderType { a: 2 }, and the length of the vector: 2, resides on the other side of the pointer.
/// ```
/// [`HeaderVec`] itself consists solely of a pointer, it's only 8 bytes big.
/// All of the data, like our header `OurHeaderType { a: 2 }`, the length of the vector: `2`,
/// and the contents of the vector `['x', 'z']` resides on the other side of the pointer.
pub struct HeaderVec<H, T> {
ptr: *mut T,
_phantom: PhantomData<H>,
Expand Down

0 comments on commit 2076db3

Please sign in to comment.