Skip to content

Commit

Permalink
Auto merge of rust-lang#97553 - nbdd0121:lib, r=Mark-Simulacrum
Browse files Browse the repository at this point in the history
Add `#[inline]` to `Vec`'s `Deref/DerefMut`

This should help rust-lang#97552 (although I haven't verified).
  • Loading branch information
bors committed Jun 1, 2022
2 parents 02916c4 + 0a7a0ff commit 395a09c
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -2495,13 +2495,15 @@ impl<T: Copy, A: Allocator> ExtendFromWithinSpec for Vec<T, A> {
impl<T, A: Allocator> ops::Deref for Vec<T, A> {
type Target = [T];

#[inline]
fn deref(&self) -> &[T] {
unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
}
}

#[stable(feature = "rust1", since = "1.0.0")]
impl<T, A: Allocator> ops::DerefMut for Vec<T, A> {
#[inline]
fn deref_mut(&mut self) -> &mut [T] {
unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
}
Expand Down

0 comments on commit 395a09c

Please sign in to comment.