Skip to content

Commit 07ba1fd

Browse files
committed
docs: Mention spare_capacity_mut() in Vec::set_len
1 parent 1be24d7 commit 07ba1fd

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

library/alloc/src/vec/mod.rs

+6-1
Original file line numberDiff line numberDiff line change
@@ -1420,7 +1420,10 @@ impl<T, A: Allocator> Vec<T, A> {
14201420
///
14211421
/// # Examples
14221422
///
1423-
/// This method can be useful for situations in which the vector
1423+
/// See [`spare_capacity_mut()`] for an example with safe
1424+
/// initialization of capacity elements and use of this method.
1425+
///
1426+
/// `set_len()` can be useful for situations in which the vector
14241427
/// is serving as a buffer for other code, particularly over FFI:
14251428
///
14261429
/// ```no_run
@@ -1477,6 +1480,8 @@ impl<T, A: Allocator> Vec<T, A> {
14771480
///
14781481
/// Normally, here, one would use [`clear`] instead to correctly drop
14791482
/// the contents and thus not leak memory.
1483+
///
1484+
/// [`spare_capacity_mut()`]: Vec::spare_capacity_mut
14801485
#[inline]
14811486
#[stable(feature = "rust1", since = "1.0.0")]
14821487
pub unsafe fn set_len(&mut self, new_len: usize) {

0 commit comments

Comments
 (0)