Repository navigation
refactor: deprecate as_slice and as_mut_slice in favor of AsRef/AsMut (#711) - #763
Merged
Merged
Conversation
Contributor
Author
|
Hi @alejandro-vaz, I have implemented the deprecations according to your feedback:
Looking forward to your review! |
alejandro-vaz
requested changes
Oct 16, 2026
Comment on lines
83
to
91
| @@ -60,6 +90,10 @@ impl<Item, const INLINE: usize, Heap: Allocator> IntoIter<Item, INLINE, Heap> { | |||
| } | |||
| } | |||
Collaborator
There was a problem hiding this comment.
change how this works to simply call as_ref
| note = "use `<IntoIter<Item, INLINE, Heap> as AsMut<[Item]>>::as_mut` instead" | ||
| )] | ||
| #[inline] | ||
| pub const fn as_mut_slice(&mut self) -> &mut [Item] { |
Comment on lines
978
to
982
| pub const fn as_slice(&self) -> &[Item] { | ||
| let (length, on_heap) = self.length.parts(); | ||
| // SAFETY: all the elements in `..length` are initialized | ||
| unsafe { core::slice::from_raw_parts(self.raw.as_ptr(on_heap), length) } | ||
| } |
Collaborator
There was a problem hiding this comment.
same, let this be a simple as_ref
| note = "use `<SmallVec<Item, INLINE, Heap> as AsMut<[Item]>>::as_mut` instead" | ||
| )] | ||
| #[inline] | ||
| pub const fn as_mut_slice(&mut self) -> &mut [Item] { |
Contributor
Author
|
i will solve this faster in few minutes |
Collaborator
|
what happened?? |
Contributor
Author
|
Yeah just give me 10 minutes I will work on the feedback |
Contributor
Author
|
I have updated the implementation according to your feedback @alejandro-vaz sir |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Addresses the deprecation of
as_sliceandas_mut_sliceas discussed in the request for comments under the v2 deprecations tracking issue (#711).In idiomatic Rust, standard trait implementations (
AsRef<[T]>andAsMut<[T]>) are preferred over bespoke accessor methods. Following maintainer feedback (@alejandro-vaz):SmallVec::as_sliceandSmallVec::as_mut_slicewith#[deprecated(since = "2.0.0-beta.3", note = "use<SmallVec<Item, INLINE, Heap> as AsRef<[Item]>>::as_refinstead")].IntoIter::as_sliceandIntoIter::as_mut_slicewith#[deprecated(since = "2.0.0-beta.3", ...)]and implementedAsRef<[Item]>andAsMut<[Item]>forIntoIter.Drain::as_slicewith#[deprecated(since = "2.0.0-beta.3", ...)]and implementedAsRef<[Item]>forDrain.src/references.rs,src/comparisons.rs,src/specialization.rs,src/iterators/extractif.rs) to use.as_ref()/.as_mut().AsRefonIntoIterandDrain, and added#[allow(deprecated)]to the legacy slice tests.cargo +nightly fmt -- --check.Related to #711