Skip to content

Commit d6dbb2d

Browse files
qkniepclaude
andcommitted
docs: make doc-comment summaries rustdoc-first
Reshape compound first paragraphs across the public API so each item leads with a terse single-sentence summary, then a blank line, then the detail. Rustdoc uses the first paragraph as the listing/search summary, so an em-dash aside or colon-introduced elaboration tacked onto the summary rendered poorly. Pure doc-comment reshaping: no code, no technical claims, links, complexity notes, or `# Errors`/`# Panics`/`# Examples` sections changed. Also lightly de-nests the deepest em-dash/colon chains as a side effect of the split. Semantic line breaks were considered and rejected (unsupported by rustfmt, against the fixed-width house style); benchmark-ratio rationale already lives in `//` maintainer comments, not `///`, so nothing needed relocating. Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
1 parent 3ef93eb commit d6dbb2d

10 files changed

Lines changed: 324 additions & 263 deletions

File tree

src/bag.rs

Lines changed: 26 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -61,15 +61,17 @@ impl<S: Store> Bag<S> {
6161
pub fn from_store(store: S) -> Self {
6262
Bag { store }
6363
}
64-
/// Borrows the backing store, for backend-specific introspection
65-
/// (`spilled()`, allocated capacity, …) — see
64+
/// Borrows the backing store.
65+
///
66+
/// For backend-specific introspection (`spilled()`, allocated capacity, …) — see
6667
/// [`SortedSet::store`](crate::SortedSet::store).
6768
#[must_use]
6869
pub fn store(&self) -> &S {
6970
&self.store
7071
}
71-
/// Consumes the bag and hands back its store, elements intact and in
72-
/// insertion order — the inverse of [`from_store`](Self::from_store).
72+
/// Consumes the bag and returns its store, elements intact and in insertion order.
73+
///
74+
/// The inverse of [`from_store`](Self::from_store).
7375
#[must_use]
7476
pub fn into_store(self) -> S {
7577
self.store
@@ -118,10 +120,10 @@ impl<S: Store> Bag<S> {
118120
{
119121
chunked_contains(self.store.as_slice(), value)
120122
}
121-
/// Returns how many elements equal `value` — the multiset multiplicity. `O(n)`.
123+
/// Returns how many elements equal `value`.
122124
///
123-
/// `value` may be any borrowed form of the element type, like
124-
/// [`contains`](Self::contains).
125+
/// The multiset multiplicity, `O(n)`. `value` may be any borrowed form of the element
126+
/// type, like [`contains`](Self::contains).
125127
#[must_use]
126128
pub fn count<Q>(&self, value: &Q) -> usize
127129
where
@@ -166,8 +168,9 @@ impl<S: StoreMut> Bag<S> {
166168
self.store.clear();
167169
}
168170

169-
/// Pre-allocates so at least `additional` more elements fit without a
170-
/// reallocation — see [`SortedSet::reserve`](crate::SortedSet::reserve).
171+
/// Pre-allocates so at least `additional` more elements fit without a reallocation.
172+
///
173+
/// See [`SortedSet::reserve`](crate::SortedSet::reserve).
171174
pub fn reserve(&mut self, additional: usize) {
172175
self.store.reserve(additional);
173176
}
@@ -188,10 +191,11 @@ impl<S: StoreMut> Bag<S> {
188191
(len > 0).then(|| self.store.remove_at(len - 1))
189192
}
190193

191-
/// Removes and returns the element at `i` by swapping the last element into its place
192-
/// — `O(1)`, but **does not preserve order**.
194+
/// Removes and returns the element at `i` by swapping the last element into its
195+
/// place.
193196
///
194-
/// Prefer this over [`remove`](Self::remove) when order doesn't matter.
197+
/// `O(1)`, but **does not preserve order**. Prefer this over [`remove`](Self::remove)
198+
/// when order doesn't matter.
195199
///
196200
/// # Panics
197201
///
@@ -200,8 +204,9 @@ impl<S: StoreMut> Bag<S> {
200204
self.store.swap_remove_at(i)
201205
}
202206

203-
/// Removes and returns the element at `i`, shifting the tail down to preserve
204-
/// order — `O(n)`.
207+
/// Removes and returns the element at `i`, shifting the tail down to preserve order.
208+
///
209+
/// `O(n)`.
205210
///
206211
/// # Panics
207212
///
@@ -246,8 +251,9 @@ impl<S: StoreMut + StoreNew> Bag<S> {
246251
}
247252

248253
impl<S: StoreMut + Unbounded> Bag<S> {
249-
/// Infallibly appends `value` — available only when the backing store is
250-
/// [`Unbounded`].
254+
/// Infallibly appends `value`.
255+
///
256+
/// Available only when the backing store is [`Unbounded`].
251257
pub fn push(&mut self, value: S::Elem) {
252258
match self.try_push(value) {
253259
Ok(()) => {}
@@ -293,10 +299,11 @@ impl<S> FromIterator<S::Elem> for Bag<S>
293299
where
294300
S: StoreMut + StoreNew + Unbounded,
295301
{
296-
/// Collects an iterator into a bag — `O(n)`, no dedup, no element bound.
302+
/// Collects an iterator into a bag.
297303
///
298-
/// Unlike the maps (whose duplicate-key policy makes a fallible build), a bag's
299-
/// `FromIterator` can't fail on an [`Unbounded`] store.
304+
/// `O(n)`, no dedup, no element bound. Unlike the maps (whose duplicate-key policy
305+
/// makes a fallible build), a bag's `FromIterator` can't fail on an [`Unbounded`]
306+
/// store.
300307
fn from_iter<I: IntoIterator<Item = S::Elem>>(iter: I) -> Self {
301308
match Bag::try_from_iter(iter) {
302309
Ok(bag) => bag,

src/column_map.rs

Lines changed: 53 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -101,13 +101,12 @@ where
101101
.map(|i| offset + i)
102102
}
103103

104-
/// Iterator over a column map's entries as `(&K, &V)` pairs — what
105-
/// [`UnsortedColumnMap::iter`] and
106-
/// [`SortedColumnMap::iter`](crate::SortedColumnMap::iter) return, and what `&map`
107-
/// iterates as.
104+
/// Iterator over a column map's entries as `(&K, &V)` pairs.
108105
///
109-
/// Zips the two dense column slices back into entries; double-ended, exact-size,
110-
/// and fused, like the slice iterators underneath.
106+
/// What [`UnsortedColumnMap::iter`] and
107+
/// [`SortedColumnMap::iter`](crate::SortedColumnMap::iter) return, and what `&map`
108+
/// iterates as. Zips the two dense column slices back into entries; double-ended,
109+
/// exact-size, and fused, like the slice iterators underneath.
111110
// A named struct rather than a bare `Zip<…>` alias, so the returned type is
112111
// nameable and stable while the two-store representation stays private —
113112
// mirroring [`MapIter`](crate::MapIter) for the single-store maps.
@@ -186,14 +185,14 @@ impl<K, V> ExactSizeIterator for ColumnIter<'_, K, V> {
186185

187186
impl<K, V> core::iter::FusedIterator for ColumnIter<'_, K, V> {}
188187

189-
/// Iterator over a column map's entries as `(&K, &mut V)` pairs — what
190-
/// [`UnsortedColumnMap::iter_mut`] and
191-
/// [`SortedColumnMap::iter_mut`](crate::SortedColumnMap::iter_mut) return.
188+
/// Iterator over a column map's entries as `(&K, &mut V)` pairs.
192189
///
193-
/// Zips the dense key column against a mutable walk of the value column;
194-
/// double-ended, exact-size, and fused. Not cloneable — the value borrows are unique;
195-
/// the key stays shared so map invariants can't be broken through it. Named like
196-
/// [`ColumnIter`] so the return type is nameable and stable.
190+
/// What [`UnsortedColumnMap::iter_mut`] and
191+
/// [`SortedColumnMap::iter_mut`](crate::SortedColumnMap::iter_mut) return. Zips the dense
192+
/// key column against a mutable walk of the value column; double-ended, exact-size, and
193+
/// fused. Not cloneable — the value borrows are unique; the key stays shared so map
194+
/// invariants can't be broken through it. Named like [`ColumnIter`] so the return type is
195+
/// nameable and stable.
197196
#[derive(Debug)]
198197
pub struct ColumnIterMut<'a, K, V> {
199198
inner: core::iter::Zip<core::slice::Iter<'a, K>, core::slice::IterMut<'a, V>>,
@@ -257,12 +256,12 @@ impl<K, V> ExactSizeIterator for ColumnIterMut<'_, K, V> {
257256

258257
impl<K, V> core::iter::FusedIterator for ColumnIterMut<'_, K, V> {}
259258

260-
/// Mutable iterator over a column map's values — what
261-
/// [`UnsortedColumnMap::values_mut`] and
262-
/// [`SortedColumnMap::values_mut`](crate::SortedColumnMap::values_mut) return.
259+
/// Mutable iterator over a column map's values.
263260
///
264-
/// A thin wrapper over the value column's `&mut [V]` slice iterator (double-ended,
265-
/// exact-size, fused). Not cloneable — the value borrows are unique.
261+
/// What [`UnsortedColumnMap::values_mut`] and
262+
/// [`SortedColumnMap::values_mut`](crate::SortedColumnMap::values_mut) return. A thin
263+
/// wrapper over the value column's `&mut [V]` slice iterator (double-ended, exact-size,
264+
/// fused). Not cloneable — the value borrows are unique.
266265
#[derive(Debug)]
267266
pub struct ColumnValuesMut<'a, V> {
268267
inner: core::slice::IterMut<'a, V>,
@@ -361,12 +360,12 @@ pub(crate) fn retain_columns<K, V, SK, SV>(
361360
}
362361
}
363362

364-
/// A map with no key ordering, stored **column-wise**: keys in `SK`, values in `SV`, kept
365-
/// the same length.
363+
/// A map with no key ordering, stored **column-wise**.
366364
///
367-
/// The struct-of-arrays counterpart of [`UnsortedMap`](crate::UnsortedMap) — trades the
368-
/// `&[(K, V)]` view for a dense, value-free key scan (faster for large values; see the
369-
/// module docs). Needs only `K: Eq`.
365+
/// Keys live in `SK`, values in `SV`, kept the same length. The struct-of-arrays
366+
/// counterpart of [`UnsortedMap`](crate::UnsortedMap) — trades the `&[(K, V)]` view for a
367+
/// dense, value-free key scan (faster for large values; see the module docs). Needs only
368+
/// `K: Eq`.
370369
///
371370
/// Panicking key/value destructors are unsupported: the two columns are mutated in
372371
/// sequence, so a destructor that unwinds mid-mutation (in [`remove`](Self::remove),
@@ -417,9 +416,9 @@ impl<SK: Store, SV: Store> UnsortedColumnMap<SK, SV> {
417416
pub fn max_capacity(&self) -> Option<usize> {
418417
combined_capacity(self.keys.max_capacity(), self.values.max_capacity())
419418
}
420-
/// Returns the keys as a contiguous slice — the dense scan target.
419+
/// Returns the keys as a contiguous slice.
421420
///
422-
/// `zip` with [`values`](Self::values) to iterate entries.
421+
/// The dense scan target. `zip` with [`values`](Self::values) to iterate entries.
423422
#[must_use]
424423
pub fn keys(&self) -> &[SK::Elem] {
425424
self.keys.as_slice()
@@ -433,19 +432,20 @@ impl<SK: Store, SV: Store> UnsortedColumnMap<SK, SV> {
433432
}
434433

435434
impl<SK: Store, SV: Store> UnsortedColumnMap<SK, SV> {
436-
/// Borrows the two backing stores, `(keys, values)` — the door to backend-specific
437-
/// introspection (`spilled()`, allocated capacity, …), as
438-
/// [`SortedSet::store`](crate::SortedSet::store) is for the single-store collections.
435+
/// Borrows the two backing stores, `(keys, values)`.
439436
///
440-
/// Shared-ref only: `&mut` access could desync the columns or smuggle in a duplicate
441-
/// key.
437+
/// The door to backend-specific introspection (`spilled()`, allocated capacity, …),
438+
/// as [`SortedSet::store`](crate::SortedSet::store) is for the single-store
439+
/// collections. Shared-ref only: `&mut` access could desync the columns or
440+
/// smuggle in a duplicate key.
442441
#[must_use]
443442
pub fn stores(&self) -> (&SK, &SV) {
444443
(&self.keys, &self.values)
445444
}
446-
/// Consumes the map and hands back its stores, `(keys, values)`, entries
447-
/// intact and index-aligned — the inverse of
448-
/// [`from_store`](Self::from_store).
445+
/// Consumes the map and returns its stores, `(keys, values)`, entries intact and
446+
/// index-aligned.
447+
///
448+
/// The inverse of [`from_store`](Self::from_store).
449449
#[must_use]
450450
pub fn into_stores(self) -> (SK, SV) {
451451
(self.keys, self.values)
@@ -460,9 +460,10 @@ impl<SK: StoreMut, SV: StoreMut> UnsortedColumnMap<SK, SV> {
460460
self.keys.clear();
461461
self.values.clear();
462462
}
463-
/// Pre-allocates both columns so at least `additional` more entries fit
464-
/// without a reallocation — see
465-
/// [`SortedSet::reserve`](crate::SortedSet::reserve).
463+
/// Pre-allocates both columns so at least `additional` more entries fit without a
464+
/// reallocation.
465+
///
466+
/// See [`SortedSet::reserve`](crate::SortedSet::reserve).
466467
pub fn reserve(&mut self, additional: usize) {
467468
self.keys.reserve(additional);
468469
self.values.reserve(additional);
@@ -493,8 +494,9 @@ where
493494
SK: StoreMut<Elem = K>,
494495
SV: StoreMut<Elem = V>,
495496
{
496-
/// Returns an iterator over the entries as `(&K, &mut V)` pairs — bulk in-place value
497-
/// updates, the dense `&mut [V]` walk SoA vectorizes best.
497+
/// Returns an iterator over the entries as `(&K, &mut V)` pairs.
498+
///
499+
/// Bulk in-place value updates, the dense `&mut [V]` walk SoA vectorizes best.
498500
#[must_use]
499501
pub fn iter_mut(&mut self) -> ColumnIterMut<'_, K, V> {
500502
ColumnIterMut::new(self.keys.as_slice(), self.values.as_mut_slice())
@@ -521,11 +523,11 @@ where
521523
SV: Store<Elem = V>,
522524
K: Eq,
523525
{
524-
/// Wraps two stores **assumed equal-length and free of duplicate keys** — the
525-
/// column-map invariants.
526+
/// Wraps two stores **assumed equal-length and free of duplicate keys**.
526527
///
527-
/// No scan or alignment is performed; a length mismatch would desync key/value pairs
528-
/// and a duplicate key would shadow itself. Both preconditions are
528+
/// The column-map invariants. No scan or alignment is performed; a length mismatch
529+
/// would desync key/value pairs and a duplicate key would shadow itself. Both
530+
/// preconditions are
529531
/// `debug_assert!`-checked (zero cost in release). To build from an arbitrary
530532
/// iterator, use [`try_from_iter`](Self::try_from_iter).
531533
///
@@ -608,10 +610,10 @@ where
608610
SV: StoreMut<Elem = V>,
609611
K: Eq,
610612
{
611-
/// Returns a mutable reference to `key`'s value, or `None` if absent — for an
612-
/// in-place update without the [`entry`](Self::entry) ceremony.
613+
/// Returns a mutable reference to `key`'s value, or `None` if absent.
613614
///
614-
/// No E0311 lifetime dance (unlike
615+
/// For an in-place update without the [`entry`](Self::entry) ceremony. No E0311
616+
/// lifetime dance (unlike
615617
/// [`UnsortedMap::get_mut`](crate::UnsortedMap::get_mut)): the value column is
616618
/// already `&mut [V]`, so elision ties the result to `&mut self`. `key` may be any
617619
/// borrowed form of `K`, like [`get`](Self::get).
@@ -771,10 +773,10 @@ where
771773
SV: StoreMut<Elem = V> + Unbounded,
772774
K: Eq,
773775
{
774-
/// Infallibly inserts or replaces, returning the previous value — available only when
775-
/// **both** columns are [`Unbounded`].
776+
/// Infallibly inserts or replaces, returning the previous value.
776777
///
777-
/// The infallible twin of [`try_insert`](Self::try_insert).
778+
/// Available only when **both** columns are [`Unbounded`]. The infallible twin of
779+
/// [`try_insert`](Self::try_insert).
778780
pub fn insert(&mut self, key: K, value: V) -> Option<V> {
779781
match self.try_insert(key, value) {
780782
Ok(prev) => prev,
@@ -821,10 +823,10 @@ where
821823
SV: StoreMut<Elem = V> + Unbounded,
822824
K: Eq,
823825
{
824-
/// Extends the map, last-wins and infallible — available only when **both** columns
825-
/// are [`Unbounded`].
826+
/// Extends the map, last-wins and infallible.
826827
///
827-
/// As with [`UnsortedMap`](crate::UnsortedMap), there is deliberately no
828+
/// Available only when **both** columns are [`Unbounded`]. As with
829+
/// [`UnsortedMap`](crate::UnsortedMap), there is deliberately no
828830
/// `FromIterator`: fresh construction rejects duplicate keys, while `extend`
829831
/// overrides them.
830832
fn extend<I: IntoIterator<Item = (K, V)>>(&mut self, iter: I) {

src/column_map/entry.rs

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -107,8 +107,9 @@ where
107107
}
108108
}
109109

110-
/// Runs `f` on the value if the key is present, then returns the entry — for
111-
/// the update half of an update-or-insert chained before `or_insert`.
110+
/// Runs `f` on the value if the key is present, then returns the entry.
111+
///
112+
/// For the update half of an update-or-insert chained before `or_insert`.
112113
pub fn and_modify<F: FnOnce(&mut V)>(mut self, f: F) -> Self {
113114
if let ColumnEntry::Occupied(e) = &mut self {
114115
f(e.get_mut());

0 commit comments

Comments
 (0)