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 Oct 31, 2023
1 parent f290006 commit 29954b4
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 2 deletions.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
- `defmt-impl` is now `defmt-03`
- `ufmt-impl` is now `ufmt`
- `cas` is removed, atomic polyfilling is now opt-in via the `portable-atomic` feature.
- `Vec::as_mut_slice` is now a public method.

### Fixed

Expand Down
4 changes: 2 additions & 2 deletions src/vec.rs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,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 @@ -168,7 +168,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 29954b4

Please sign in to comment.