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.
This commit is contained in:
parent
b6fa392238
commit
79449986b7
|
@ -1900,6 +1900,22 @@ unsafe impl<T: ?Sized> IsZero for Option<Box<T>> {
|
||||||
// Common trait implementations for Vec
|
// Common trait implementations for Vec
|
||||||
////////////////////////////////////////////////////////////////////////////////
|
////////////////////////////////////////////////////////////////////////////////
|
||||||
|
|
||||||
|
#[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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T: Clone> Clone for Vec<T> {
|
impl<T: Clone> Clone for Vec<T> {
|
||||||
#[cfg(not(test))]
|
#[cfg(not(test))]
|
||||||
|
@ -1955,22 +1971,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")]
|
#[stable(feature = "rust1", since = "1.0.0")]
|
||||||
impl<T> FromIterator<T> for Vec<T> {
|
impl<T> FromIterator<T> for Vec<T> {
|
||||||
#[inline]
|
#[inline]
|
||||||
|
|
Loading…
Reference in New Issue