Skip to content

Commit 6b8fa5d

Browse files
committed
Further doc improvements for into_boxed_slice and shrink_to_fit
1 parent c4c01f0 commit 6b8fa5d

File tree

1 file changed

+6
-5
lines changed

1 file changed

+6
-5
lines changed

library/alloc/src/vec/mod.rs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1023,8 +1023,10 @@ impl<T, A: Allocator> Vec<T, A> {
10231023

10241024
/// Shrinks the capacity of the vector as much as possible.
10251025
///
1026-
/// It will drop down as close as possible to the length but the allocator
1027-
/// may still inform the vector that there is space for a few more elements.
1026+
/// The behavior of this method depends on the allocator being used. If the allocator supports
1027+
/// in-place shrinking, some or all of the excess capacity may be returned to the allocator.
1028+
/// If not, this method may cause the vector's data to be copied to a new allocation with
1029+
/// exactly the correct size. See [`Allocator::shrink`] for more details.
10281030
///
10291031
/// # Examples
10301032
///
@@ -1074,11 +1076,10 @@ impl<T, A: Allocator> Vec<T, A> {
10741076

10751077
/// Converts the vector into [`Box<[T]>`][owned slice].
10761078
///
1077-
/// If the vector has excess capacity, it will shrink down as close as
1078-
/// possible to the length but the allocator may still inform the vector
1079-
/// that there is space for a few more elements.
1079+
/// Before doing the conversion, this method calls [`shrink_to_fit`] to remove excess capacity.
10801080
///
10811081
/// [owned slice]: Box
1082+
/// [`shrink_to_fit`]: Vec::shrink_to_fit
10821083
///
10831084
/// # Examples
10841085
///

0 commit comments

Comments
 (0)