From 0b61af33b8ca22b360411876e4920efa97897f89 Mon Sep 17 00:00:00 2001 From: Baptistemontan Date: Wed, 16 Sep 2026 16:59:32 +0200 Subject: [PATCH 1/2] update zst doc --- src/lib.rs | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 69d5e16..457a354 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,12 +14,11 @@ //! * `ThinVec::new()` doesn't allocate (it points to a statically allocated singleton) //! * reallocation can be done in place //! * `size_of::>()` == `size_of::>>()` +//! * Does'nt allocate for Zero Sized Types (e.g. `ThinVec<()>`), but only without the "gecko-ffi" feature. //! //! Properties of `Vec` that aren't preserved: //! * `ThinVec` can't ever be zero-cost roundtripped to a `Box<[T]>`, `String`, or `*mut T` //! * `from_raw_parts` doesn't exist -//! * `ThinVec` currently doesn't bother to not-allocate for Zero Sized Types (e.g. `ThinVec<()>`), -//! but it could be done if someone cared enough to implement it. //! //! //! # Optional Features @@ -575,10 +574,8 @@ impl ThinVec { /// If it is important to know the exact allocated capacity of a `ThinVec`, /// always use the [`capacity`] method after construction. /// - /// **NOTE**: unlike `Vec`, `ThinVec` **MUST** allocate once to keep track of non-zero - /// lengths. As such, we cannot provide the same guarantees about ThinVecs - /// of ZSTs not allocating. However the allocation never needs to be resized - /// to add more ZSTs, since the underlying array is still length 0. + /// **NOTE**: like `Vec`, `ThinVec` does'nt allocate for ZSTs and store the length inline, + /// but creating a `ThinVec` of ZSTs is not allowed if the "gecko-ffi" feature is enabled. /// /// [Capacity and reallocation]: #capacity-and-reallocation /// [`capacity`]: Vec::capacity @@ -611,8 +608,7 @@ impl ThinVec { /// assert!(vec.capacity() >= 11); /// /// # #[cfg(not(feature = "gecko-ffi"))] { - /// // A vector of a zero-sized type will always over-allocate, since no - /// // space is needed to store the actual elements. + /// // A vector of a zero-sized type will not allocate and report to have max capacity. /// // Note this is only true **without** the gecko-ffi feature! /// let vec_units = ThinVec::<()>::with_capacity(10); /// assert_eq!(vec_units.capacity(), usize::MAX - 1); From 51588cf505c458bd82f97fbd1f44c59e13ac4e8b Mon Sep 17 00:00:00 2001 From: Baptistemontan Date: Wed, 16 Sep 2026 17:36:57 +0200 Subject: [PATCH 2/2] fix typos --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 457a354..3cf70d3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -14,7 +14,7 @@ //! * `ThinVec::new()` doesn't allocate (it points to a statically allocated singleton) //! * reallocation can be done in place //! * `size_of::>()` == `size_of::>>()` -//! * Does'nt allocate for Zero Sized Types (e.g. `ThinVec<()>`), but only without the "gecko-ffi" feature. +//! * Doesn't allocate for Zero Sized Types (e.g. `ThinVec<()>`), but only without the "gecko-ffi" feature. //! //! Properties of `Vec` that aren't preserved: //! * `ThinVec` can't ever be zero-cost roundtripped to a `Box<[T]>`, `String`, or `*mut T` @@ -574,7 +574,7 @@ impl ThinVec { /// If it is important to know the exact allocated capacity of a `ThinVec`, /// always use the [`capacity`] method after construction. /// - /// **NOTE**: like `Vec`, `ThinVec` does'nt allocate for ZSTs and store the length inline, + /// **NOTE**: like `Vec`, `ThinVec` doesn't allocate for ZSTs and stores the length inline, /// but creating a `ThinVec` of ZSTs is not allowed if the "gecko-ffi" feature is enabled. /// /// [Capacity and reallocation]: #capacity-and-reallocation