Skip to content
This repository was archived by the owner on May 28, 2025. It is now read-only.

Commit 7944998

Browse files
committed
Rearrange impl blocks with Deref as first
The other blocks depends on Deref to make it easier for readers when reimplementing or reading the implementations.
1 parent b6fa392 commit 7944998

File tree

1 file changed

+16
-16
lines changed

1 file changed

+16
-16
lines changed

src/liballoc/vec.rs

Lines changed: 16 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1900,6 +1900,22 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
19001900
// Common trait implementations for Vec
19011901
////////////////////////////////////////////////////////////////////////////////
19021902

1903+
#[stable(feature = "rust1", since = "1.0.0")]
1904+
impl<T> ops::Deref for Vec<T> {
1905+
type Target = [T];
1906+
1907+
fn deref(&self) -> &[T] {
1908+
unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
1909+
}
1910+
}
1911+
1912+
#[stable(feature = "rust1", since = "1.0.0")]
1913+
impl<T> ops::DerefMut for Vec<T> {
1914+
fn deref_mut(&mut self) -> &mut [T] {
1915+
unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
1916+
}
1917+
}
1918+
19031919
#[stable(feature = "rust1", since = "1.0.0")]
19041920
impl<T: Clone> Clone for Vec<T> {
19051921
#[cfg(not(test))]
@@ -1955,22 +1971,6 @@ impl<T, I: SliceIndex<[T]>> IndexMut<I> for Vec<T> {
19551971
}
19561972
}
19571973

1958-
#[stable(feature = "rust1", since = "1.0.0")]
1959-
impl<T> ops::Deref for Vec<T> {
1960-
type Target = [T];
1961-
1962-
fn deref(&self) -> &[T] {
1963-
unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
1964-
}
1965-
}
1966-
1967-
#[stable(feature = "rust1", since = "1.0.0")]
1968-
impl<T> ops::DerefMut for Vec<T> {
1969-
fn deref_mut(&mut self) -> &mut [T] {
1970-
unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
1971-
}
1972-
}
1973-
19741974
#[stable(feature = "rust1", since = "1.0.0")]
19751975
impl<T> FromIterator<T> for Vec<T> {
19761976
#[inline]

0 commit comments

Comments
 (0)