Add `#[inline]` to `Vec`'s `Deref/DerefMut`

This commit is contained in:
Gary Guo 2022-05-30 15:11:53 +01:00
parent fa70b89d19
commit 0a7a0ff4d9
1 changed files with 2 additions and 0 deletions

View File

@ -2493,6 +2493,7 @@ 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) }
}
@ -2500,6 +2501,7 @@ impl<T, A: Allocator> ops::Deref for Vec<T, A> {
#[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) }
}