Skip to content

Commit ac642ab

Browse files
committed
Update the comment some more following CR feedback
1 parent 5c11392 commit ac642ab

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed

src/liballoc/vec.rs

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -748,10 +748,10 @@ impl<T> Vec<T> {
748748
self
749749
}
750750

751-
/// Forces the length of a vector to a particular value.
751+
/// Forces the length of the vector to `new_len`.
752752
///
753753
/// This is a low-level operation that maintains none of the normal
754-
/// invariants of the type. Normally changing the length of a `Vec`
754+
/// invariants of the type. Normally changing the length of a vector
755755
/// is done using one of the safe operations instead, such as
756756
/// [`truncate`], [`resize`], [`extend`], or [`clear`].
757757
///
@@ -762,14 +762,15 @@ impl<T> Vec<T> {
762762
///
763763
/// # Safety
764764
///
765-
/// - `new_len` must be less than or equal to `capacity()`.
766-
/// - All elements between past the previous end up to the `new_len`
767-
/// must be initialized.
765+
/// - `new_len` must be less than or equal to [`capacity()`].
766+
/// - The elements at `old_len..new_len` must be initialized.
767+
///
768+
/// [`capacity()`]: #method.capacity
768769
///
769770
/// # Examples
770771
///
771-
/// This method can be useful for situations in which the `Vec` is
772-
/// serving as a buffer for other code, particularly over FFI:
772+
/// This method can be useful for situations in which the vector
773+
/// is serving as a buffer for other code, particularly over FFI:
773774
///
774775
/// ```no_run
775776
/// # #![allow(dead_code)]
@@ -786,7 +787,7 @@ impl<T> Vec<T> {
786787
/// # }
787788
/// # impl StreamWrapper {
788789
/// pub fn get_dictionary(&self) -> Option<Vec<u8>> {
789-
/// // Per the docs, "32768 bytes is always enough".
790+
/// // Per the FFI method's docs, "32768 bytes is always enough".
790791
/// let mut dict = Vec::with_capacity(32_768);
791792
/// let mut dict_length = 0;
792793
/// unsafe {
@@ -816,7 +817,8 @@ impl<T> Vec<T> {
816817
/// }
817818
/// ```
818819
///
819-
/// (Instead, one would normally use [`clear`] in this situation.)
820+
/// Normally, here, one would use [`clear`] instead to correctly drop
821+
/// the contents and thus not leak memory.
820822
#[inline]
821823
#[stable(feature = "rust1", since = "1.0.0")]
822824
pub unsafe fn set_len(&mut self, new_len: usize) {

0 commit comments

Comments
 (0)