Skip to content

Commit

Permalink
Update the comment some more following CR feedback
Browse files Browse the repository at this point in the history
  • Loading branch information
scottmcm committed Dec 12, 2018
1 parent 5c11392 commit ac642ab
Showing 1 changed file with 11 additions and 9 deletions.
20 changes: 11 additions & 9 deletions src/liballoc/vec.rs
Expand Up @@ -748,10 +748,10 @@ impl<T> Vec<T> {
self
}

/// Forces the length of a vector to a particular value.
/// Forces the length of the vector to `new_len`.
///
/// This is a low-level operation that maintains none of the normal
/// invariants of the type. Normally changing the length of a `Vec`
/// invariants of the type. Normally changing the length of a vector
/// is done using one of the safe operations instead, such as
/// [`truncate`], [`resize`], [`extend`], or [`clear`].
///
Expand All @@ -762,14 +762,15 @@ impl<T> Vec<T> {
///
/// # Safety
///
/// - `new_len` must be less than or equal to `capacity()`.
/// - All elements between past the previous end up to the `new_len`
/// must be initialized.
/// - `new_len` must be less than or equal to [`capacity()`].
/// - The elements at `old_len..new_len` must be initialized.
///
/// [`capacity()`]: #method.capacity
///
/// # Examples
///
/// This method can be useful for situations in which the `Vec` is
/// serving as a buffer for other code, particularly over FFI:
/// This method can be useful for situations in which the vector
/// is serving as a buffer for other code, particularly over FFI:
///
/// ```no_run
/// # #![allow(dead_code)]
Expand All @@ -786,7 +787,7 @@ impl<T> Vec<T> {
/// # }
/// # impl StreamWrapper {
/// pub fn get_dictionary(&self) -> Option<Vec<u8>> {
/// // Per the docs, "32768 bytes is always enough".
/// // Per the FFI method's docs, "32768 bytes is always enough".
/// let mut dict = Vec::with_capacity(32_768);
/// let mut dict_length = 0;
/// unsafe {
Expand Down Expand Up @@ -816,7 +817,8 @@ impl<T> Vec<T> {
/// }
/// ```
///
/// (Instead, one would normally use [`clear`] in this situation.)
/// Normally, here, one would use [`clear`] instead to correctly drop
/// the contents and thus not leak memory.
#[inline]
#[stable(feature = "rust1", since = "1.0.0")]
pub unsafe fn set_len(&mut self, new_len: usize) {
Expand Down

0 comments on commit ac642ab

Please sign in to comment.