From 29954b4a65b52c9fc113e922f04f6e4b3d8319c0 Mon Sep 17 00:00:00 2001 From: Jean-Pierre De Jesus DIAZ Date: Mon, 27 Feb 2023 20:57:49 +0100 Subject: [PATCH] Make Vec::as_mut_slice public Signed-off-by: Jean-Pierre De Jesus DIAZ --- CHANGELOG.md | 1 + src/vec.rs | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index b2dfeedd91..2ad88f8ba2 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -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 diff --git a/src/vec.rs b/src/vec.rs index f7e4ae380f..0dc25f1dd1 100644 --- a/src/vec.rs +++ b/src/vec.rs @@ -158,7 +158,7 @@ impl Vec { /// Extracts a mutable slice containing the entire vector. /// - /// Equivalent to `&s[..]`. + /// Equivalent to `&mut s[..]`. /// /// # Examples /// @@ -168,7 +168,7 @@ impl Vec { /// 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) }