diff options
| author | bors <bors@rust-lang.org> | 2020-06-08 16:32:49 +0000 |
|---|---|---|
| committer | bors <bors@rust-lang.org> | 2020-06-08 16:32:49 +0000 |
| commit | bc10b68e798477066d4b1ec4886a3b1cdc4feb7e (patch) | |
| tree | 1c2d58cb9bd0d9a45bc5972c256eac6db0f94a14 /src/liballoc/vec.rs | |
| parent | 73558160933b2764ed9a84b1b2b647e128eac3f8 (diff) | |
| parent | 7983e56f40e7536a645993485754c302e5090435 (diff) | |
| download | rust-bc10b68e798477066d4b1ec4886a3b1cdc4feb7e.tar.gz rust-bc10b68e798477066d4b1ec4886a3b1cdc4feb7e.zip | |
Auto merge of #73115 - RalfJung:rollup-jecowhz, r=RalfJung
Rollup of 10 pull requests Successful merges: - #72026 (Update annotate-snippets-rs to 0.8.0) - #72583 (impl AsRef<[T]> for vec::IntoIter<T>) - #72615 (Fix documentation example for gcov profiling) - #72761 (Added the documentation for the 'use' keyword) - #72799 (Add `-Z span-debug` to allow for easier debugging of proc macros) - #72811 (Liballoc impl) - #72963 (Cstring `from_raw` and `into_raw` safety precisions) - #73001 (Free `default()` forwarding to `Default::default()`) - #73075 (Add comments to `Resolve::get_module`) - #73092 (Clean up E0646) Failed merges: r? @ghost
Diffstat (limited to 'src/liballoc/vec.rs')
| -rw-r--r-- | src/liballoc/vec.rs | 39 |
1 files changed, 23 insertions, 16 deletions
diff --git a/src/liballoc/vec.rs b/src/liballoc/vec.rs index 96923ea47f3..af943ecfd48 100644 --- a/src/liballoc/vec.rs +++ b/src/liballoc/vec.rs @@ -1906,6 +1906,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> { @@ -1961,22 +1977,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> { @@ -2628,6 +2628,13 @@ impl<T> IntoIter<T> { } } +#[stable(feature = "vec_intoiter_as_ref", since = "1.46.0")] +impl<T> AsRef<[T]> for IntoIter<T> { + fn as_ref(&self) -> &[T] { + self.as_slice() + } +} + #[stable(feature = "rust1", since = "1.0.0")] unsafe impl<T: Send> Send for IntoIter<T> {} #[stable(feature = "rust1", since = "1.0.0")] |
