summary refs log tree commit diff
path: root/src/liballoc
diff options
context:
space:
mode:
authorIvan Tham <pickfire@riseup.net>2020-05-31 17:16:47 +0800
committerIvan Tham <pickfire@riseup.net>2020-05-31 17:16:47 +0800
commit79449986b707c18df92622a53d83eddd6872d8ee (patch)
tree90294e59472cc474a77395bf5c7fafb3123fb113 /src/liballoc
parentb6fa392238a459c29a47e2cf824d79a49a8ba039 (diff)
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.
Diffstat (limited to 'src/liballoc')
-rw-r--r--src/liballoc/vec.rs32
1 files changed, 16 insertions, 16 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs
index 42fb1f8c737..6409c66b081 100644
--- a/src/liballoc/vec.rs
+++ b/src/liballoc/vec.rs
@@ -1901,6 +1901,22 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
 ////////////////////////////////////////////////////////////////////////////////
 
 #[stable(feature = "rust1", since = "1.0.0")]
+impl<T> ops::Deref for Vec<T> {
+    type Target = [T];
+
+    fn deref(&self) -> &[T] {
+        unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
+impl<T> ops::DerefMut for Vec<T> {
+    fn deref_mut(&mut self) -> &mut [T] {
+        unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
+    }
+}
+
+#[stable(feature = "rust1", since = "1.0.0")]
 impl<T: Clone> Clone for Vec<T> {
     #[cfg(not(test))]
     fn clone(&self) -> Vec<T> {
@@ -1956,22 +1972,6 @@ impl<T, I: SliceIndex<[T]>> IndexMut<I> for Vec<T> {
 }
 
 #[stable(feature = "rust1", since = "1.0.0")]
-impl<T> ops::Deref for Vec<T> {
-    type Target = [T];
-
-    fn deref(&self) -> &[T] {
-        unsafe { slice::from_raw_parts(self.as_ptr(), self.len) }
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
-impl<T> ops::DerefMut for Vec<T> {
-    fn deref_mut(&mut self) -> &mut [T] {
-        unsafe { slice::from_raw_parts_mut(self.as_mut_ptr(), self.len) }
-    }
-}
-
-#[stable(feature = "rust1", since = "1.0.0")]
 impl<T> FromIterator<T> for Vec<T> {
     #[inline]
     fn from_iter<I: IntoIterator<Item = T>>(iter: I) -> Vec<T> {