You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
as_slice and as_mut_slice are accessors to the underlying slice represented by the smallvec
idiomatic rust consistently prefers trait implementations, such as AsRef and AsMut to be used over bespoke helper methods
since we only implement AsRef<[T]> and AsMut<[T]>, and not other reference-to-reference conversions, calling as_ref and as_mut on a smallvec is unambiguous
I’d love to get some feedback on a few points since this is a request for comments: @alejandro-vaz
Complete removal vs Deprecation: Since v2 allows for breaking API changes, should we completely remove as_slice and as_mut_slice from the codebase, or just mark them with #[deprecated(since="...", note="use .as_ref() instead")] to give users a smoother migration path?
Parity with standard Vec: The standard library Vec actually does have both as_slice() and as_mut_slice() methods for convenience, despite also implementing AsRef/AsMut. Does SmallVec intentionally want to diverge from Vec's API surface here to be strictly idiomatic?
Other Structs: If we remove/deprecate them on SmallVec, should we also remove as_slice() from other structs like IntoIter and Drain for consistency?
Let me know what you prefer, and I'll go ahead and implement it!
for now we will deprecate it. in rc I'll open an issue group to see which of the deprecations we should remove. these two probably won't be removed but just marked as deprecated on v2 release
Vec wouldn't be able to deprecate as_slice and as_mut_slice even if they aren't fully idiomatic because of backwards compatibility and the backlash it will get from people in the community that haven't heard about idiomatic rust
SmallVec is similar to Vec but not Vec. we can break backwards compatibility and we will do it shamelessly when it is appropriate
I do think we should simply deprecate it from all the structs that use it for now
the attribute would be: #[deprecated(since="2.0.0-beta.3", note="use <SmallVec<Item, INLINE, Heap> as AsRef<[Item]>>::as_ref instead")] or something like that, copy exactly the wording on src/macros.rs
removing the methods fully would be too big of a sudden change, but is definitely the eventual goal
Hi @alejandro-vaz, sorry for the delay! I am working on adding the #[deprecated(since = "2.0.0-beta.3", ...)] attributes to as_slice and as_mut_slice across SmallVec, IntoIter, and Drain, and updating any internal usages/tests.Lookig for feedback."
Activity
Ankit-cs commentedon Oct 7, 2026
Assign this to me
Ankit-cs commentedon Oct 8, 2026
I’d love to get some feedback on a few points since this is a request for comments:
@alejandro-vaz
Complete removal vs Deprecation: Since v2 allows for breaking API changes, should we completely remove as_slice and as_mut_slice from the codebase, or just mark them with #[deprecated(since="...", note="use .as_ref() instead")] to give users a smoother migration path?
Parity with standard Vec: The standard library Vec actually does have both as_slice() and as_mut_slice() methods for convenience, despite also implementing AsRef/AsMut. Does SmallVec intentionally want to diverge from Vec's API surface here to be strictly idiomatic?
Other Structs: If we remove/deprecate them on SmallVec, should we also remove as_slice() from other structs like IntoIter and Drain for consistency?
Let me know what you prefer, and I'll go ahead and implement it!
alejandro-vaz commentedon Oct 8, 2026
for now we will deprecate it. in rc I'll open an issue group to see which of the deprecations we should remove. these two probably won't be removed but just marked as deprecated on v2 release
Vecwouldn't be able to deprecateas_sliceandas_mut_sliceeven if they aren't fully idiomatic because of backwards compatibility and the backlash it will get from people in the community that haven't heard about idiomatic rustSmallVecis similar toVecbut notVec. we can break backwards compatibility and we will do it shamelessly when it is appropriateI do think we should simply deprecate it from all the structs that use it for now
the attribute would be:
#[deprecated(since="2.0.0-beta.3", note="use <SmallVec<Item, INLINE, Heap> as AsRef<[Item]>>::as_ref instead")]or something like that, copy exactly the wording onsrc/macros.rsremoving the methods fully would be too big of a sudden change, but is definitely the eventual goal
Ankit-cs commentedon Oct 8, 2026
OK I will try my best to do it
alejandro-vaz commentedon Oct 14, 2026
@Ankit-cs how is it going??
please do not take an issue if you are not available. it's okay but leave a notice you are not available
Ankit-cs commentedon Oct 15, 2026
@alejandro-vaz like any discord channel i can connect directly to you
Ankit-cs commentedon Oct 15, 2026
Hi @alejandro-vaz, sorry for the delay! I am working on adding the #[deprecated(since = "2.0.0-beta.3", ...)] attributes to as_slice and as_mut_slice across SmallVec, IntoIter, and Drain, and updating any internal usages/tests.Lookig for feedback."
alejandro-vaz commentedon Oct 15, 2026
just email me or leave a comment somewhere
Ankit-cs commentedon Oct 15, 2026
OK @alejandro-vaz