Skip to content

Commit ddc32d1

Browse files
authored
Rollup merge of rust-lang#99317 - yanchith:borrow-vec-ta-as-slice-t, r=Mark-Simulacrum
Borrow Vec<T, A> as [T] Hello all, When `Vec` was parametrized with `A`, the `Borrow` impls were omitted and currently `Vec<T, A>` can't be borrowed as `[T]`. This PR fixes that. This was probably missed, because the `Borrow` impls are in a different file - `src/alloc/slice.rs`. We briefly discussed this here: rust-lang/wg-allocators#96 and I was told to go ahead and make a PR :) I tested this by building the toolchain and building my code that needed the `Borrow` impl against it, but let me know if I should add any tests to this PR.
2 parents 4805c21 + aeb9497 commit ddc32d1

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

library/alloc/src/slice.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -836,14 +836,14 @@ impl<T: Clone, V: Borrow<[T]>> Join<&[T]> for [V] {
836836
////////////////////////////////////////////////////////////////////////////////
837837

838838
#[stable(feature = "rust1", since = "1.0.0")]
839-
impl<T> Borrow<[T]> for Vec<T> {
839+
impl<T, A: Allocator> Borrow<[T]> for Vec<T, A> {
840840
fn borrow(&self) -> &[T] {
841841
&self[..]
842842
}
843843
}
844844

845845
#[stable(feature = "rust1", since = "1.0.0")]
846-
impl<T> BorrowMut<[T]> for Vec<T> {
846+
impl<T, A: Allocator> BorrowMut<[T]> for Vec<T, A> {
847847
fn borrow_mut(&mut self) -> &mut [T] {
848848
&mut self[..]
849849
}

0 commit comments

Comments
 (0)