Skip to content

Commit

Permalink
docs: Mention spare_capacity_mut() in Vec::set_len
Browse files Browse the repository at this point in the history
  • Loading branch information
jan-ferdinand authored and gitbot committed Feb 20, 2025
1 parent ed7c545 commit 4b1b88d
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1824,7 +1824,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
Expand Down Expand Up @@ -1884,6 +1887,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) {
Expand Down

0 comments on commit 4b1b88d

Please sign in to comment.