diff --git a/Cargo.toml b/Cargo.toml index 3496e76..d895b5f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -30,6 +30,9 @@ version = "1.4" optional = true default-features = false +[dependencies.debuggable] +path = "../debuggable/debuggable" + [dev-dependencies.serde_test] version = "1.0" diff --git a/examples/debug_me.rs b/examples/debug_me.rs new file mode 100644 index 0000000..1336004 --- /dev/null +++ b/examples/debug_me.rs @@ -0,0 +1,10 @@ +use arrayvec::{ArrayString, ArrayVec}; +fn main() { + let mut v: ArrayVec = ArrayVec::new(); + v.extend([10, 20, 30]); + let mut names: ArrayVec = ArrayVec::new(); + names.push("alpha".into()); + names.push("beta".into()); + let s: ArrayString<16> = ArrayString::from("hello").unwrap(); + std::hint::black_box((&v, &names, &s)); // break here +} \ No newline at end of file diff --git a/src/array_string.rs b/src/array_string.rs index 227e01d..4f4c27e 100644 --- a/src/array_string.rs +++ b/src/array_string.rs @@ -34,6 +34,8 @@ use serde::{Serialize, Deserialize, Serializer, Deserializer}; /// if needed. #[derive(Copy)] #[repr(C)] +#[derive(debuggable::Debuggable)] +#[debuggable(summary = "{len} bytes")] pub struct ArrayString { // the `len` first elements of the array are initialized len: LenUint, diff --git a/src/arrayvec.rs b/src/arrayvec.rs index f646b08..68e7c1c 100644 --- a/src/arrayvec.rs +++ b/src/arrayvec.rs @@ -40,9 +40,13 @@ use crate::utils::MakeMaybeUninit; /// It offers a simple API but also dereferences to a slice, so that the full slice API is /// available. The ArrayVec can be converted into a by value iterator. #[repr(C)] +#[derive(debuggable::Debuggable)] +#[debuggable(summary = "{len} items")] pub struct ArrayVec { + #[debuggable(hide)] len: LenUint, // the `len` first elements of the array are initialized + #[debuggable(items, len = "len")] xs: [MaybeUninit; CAP], }