diff options
| author | Jan Ferdinand Sauer <ferdinand@neptune.cash> | 2024-06-07 14:43:52 +0200 |
|---|---|---|
| committer | Jan Ferdinand Sauer <ferdinand@neptune.cash> | 2024-08-19 14:49:37 +0200 |
| commit | 07ba1fdd59cbf563536c40d82c5690008d67937f (patch) | |
| tree | 1f854960a8848f0e86d2acc50d2156acd2bdccef /library/alloc/src/vec | |
| parent | 1be24d70ced0d6b8d41a48b6a28b3790f6facf4c (diff) | |
docs: Mention `spare_capacity_mut()` in `Vec::set_len`
Diffstat (limited to 'library/alloc/src/vec')
| -rw-r--r-- | library/alloc/src/vec/mod.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/alloc/src/vec/mod.rs b/library/alloc/src/vec/mod.rs index aa9b632cbed..e5a3cbcc834 100644 --- a/library/alloc/src/vec/mod.rs +++ b/library/alloc/src/vec/mod.rs @@ -1420,7 +1420,10 @@ impl<T, A: Allocator> Vec<T, A> { /// /// # Examples /// - /// This method can be useful for situations in which the vector + /// See [`spare_capacity_mut()`] for an example with safe + /// initialization of capacity elements and use of this method. + /// + /// `set_len()` can be useful for situations in which the vector /// is serving as a buffer for other code, particularly over FFI: /// /// ```no_run @@ -1477,6 +1480,8 @@ impl<T, A: Allocator> Vec<T, A> { /// /// Normally, here, one would use [`clear`] instead to correctly drop /// the contents and thus not leak memory. + /// + /// [`spare_capacity_mut()`]: Vec::spare_capacity_mut #[inline] #[stable(feature = "rust1", since = "1.0.0")] pub unsafe fn set_len(&mut self, new_len: usize) { |
