Skip to content

Commit

Permalink
Add #[inline] to Vec's Deref/DerefMut
Browse files Browse the repository at this point in the history
  • Loading branch information
nbdd0121 committed May 30, 2022
1 parent fa70b89 commit 0a7a0ff
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
@@ -2493,13 +2493,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) }
}

0 comments on commit 0a7a0ff

Please sign in to comment.