Skip to content

Commit

Permalink
Rollup merge of #121648 - jieyouxu:from-into-raw-parts-docs, r=Nilstrieb
Browse files Browse the repository at this point in the history
Update Vec and String `{from,into}_raw_parts`-family docs

- Fix documentation argument order to match the code argument order for consistency.
- Add return argument description for `{Vec,String}::into_raw_parts` to match their `from*` counterparts.
  • Loading branch information
matthiaskrgr authored Feb 26, 2024
2 parents e47d814 + bfeea29 commit 94609db
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
4 changes: 2 additions & 2 deletions library/alloc/src/string.rs
Original file line number Diff line number Diff line change
Expand Up @@ -864,7 +864,7 @@ impl String {
}
}

/// Decomposes a `String` into its raw components.
/// Decomposes a `String` into its raw components: `(pointer, length, capacity)`.
///
/// Returns the raw pointer to the underlying data, the length of
/// the string (in bytes), and the allocated capacity of the data
Expand Down Expand Up @@ -896,7 +896,7 @@ impl String {
self.vec.into_raw_parts()
}

/// Creates a new `String` from a length, capacity, and pointer.
/// Creates a new `String` from a pointer, a length and a capacity.
///
/// # Safety
///
Expand Down
8 changes: 4 additions & 4 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -481,7 +481,7 @@ impl<T> Vec<T> {
Self::with_capacity_in(capacity, Global)
}

/// Creates a `Vec<T>` directly from a pointer, a capacity, and a length.
/// Creates a `Vec<T>` directly from a pointer, a length, and a capacity.
///
/// # Safety
///
Expand Down Expand Up @@ -672,7 +672,7 @@ impl<T, A: Allocator> Vec<T, A> {
Vec { buf: RawVec::with_capacity_in(capacity, alloc), len: 0 }
}

/// Creates a `Vec<T, A>` directly from a pointer, a capacity, a length,
/// Creates a `Vec<T, A>` directly from a pointer, a length, a capacity,
/// and an allocator.
///
/// # Safety
Expand Down Expand Up @@ -786,7 +786,7 @@ impl<T, A: Allocator> Vec<T, A> {
unsafe { Vec { buf: RawVec::from_raw_parts_in(ptr, capacity, alloc), len: length } }
}

/// Decomposes a `Vec<T>` into its raw components.
/// Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity)`.
///
/// Returns the raw pointer to the underlying data, the length of
/// the vector (in elements), and the allocated capacity of the
Expand Down Expand Up @@ -824,7 +824,7 @@ impl<T, A: Allocator> Vec<T, A> {
(me.as_mut_ptr(), me.len(), me.capacity())
}

/// Decomposes a `Vec<T>` into its raw components.
/// Decomposes a `Vec<T>` into its raw components: `(pointer, length, capacity, allocator)`.
///
/// Returns the raw pointer to the underlying data, the length of the vector (in elements),
/// the allocated capacity of the data (in elements), and the allocator. These are the same
Expand Down

0 comments on commit 94609db

Please sign in to comment.