Skip to content

Commit

Permalink
Make Vec::as_mut_slice public
Browse files Browse the repository at this point in the history
Signed-off-by: Jean-Pierre De Jesus DIAZ <[email protected]>
  • Loading branch information
jeandudey committed Feb 27, 2023
1 parent 644653b commit dd28498
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl<T, const N: usize> Vec<T, N> {

/// Extracts a mutable slice containing the entire vector.
///
/// Equivalent to `&s[..]`.
/// Equivalent to `&mut s[..]`.
///
/// # Examples
///
Expand All @@ -171,7 +171,7 @@ impl<T, const N: usize> Vec<T, N> {
/// buffer[0] = 9;
/// assert_eq!(buffer.as_slice(), &[9, 2, 3, 5, 8]);
/// ```
pub(crate) fn as_mut_slice(&mut self) -> &mut [T] {
pub fn as_mut_slice(&mut self) -> &mut [T] {
// NOTE(unsafe) avoid bound checks in the slicing operation
// &mut buffer[..self.len]
unsafe { slice::from_raw_parts_mut(self.buffer.as_mut_ptr() as *mut T, self.len) }
Expand Down

0 comments on commit dd28498

Please sign in to comment.