rename internal helper trait AsIntoIter to AsVecIntoIter
This commit is contained in:
parent
a1a602adde
commit
7549cfa599
4 changed files with 10 additions and 10 deletions
|
@ -151,7 +151,7 @@ use core::ptr;
|
|||
|
||||
use crate::collections::TryReserveError;
|
||||
use crate::slice;
|
||||
use crate::vec::{self, AsIntoIter, Vec};
|
||||
use crate::vec::{self, AsVecIntoIter, Vec};
|
||||
|
||||
use super::SpecExtend;
|
||||
|
||||
|
@ -1418,7 +1418,7 @@ unsafe impl<T> SourceIter for IntoIter<T> {
|
|||
#[doc(hidden)]
|
||||
unsafe impl<I> InPlaceIterable for IntoIter<I> {}
|
||||
|
||||
unsafe impl<I> AsIntoIter for IntoIter<I> {
|
||||
unsafe impl<I> AsVecIntoIter for IntoIter<I> {
|
||||
type Item = I;
|
||||
|
||||
fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> {
|
||||
|
|
|
@ -16,7 +16,7 @@
|
|||
//! `FromIterator` implementation benefit from this too.
|
||||
//!
|
||||
//! Access to the underlying source goes through a further layer of indirection via the private
|
||||
//! trait [`AsIntoIter`] to hide the implementation detail that other collections may use
|
||||
//! trait [`AsVecIntoIter`] to hide the implementation detail that other collections may use
|
||||
//! `vec::IntoIter` internally.
|
||||
//!
|
||||
//! In-place iteration depends on the interaction of several unsafe traits, implementation
|
||||
|
@ -142,16 +142,16 @@ impl<T> InPlaceIterableMarker for T where T: InPlaceIterable {}
|
|||
|
||||
impl<T, I> SpecFromIter<T, I> for Vec<T>
|
||||
where
|
||||
I: Iterator<Item = T> + SourceIter<Source: AsIntoIter> + InPlaceIterableMarker,
|
||||
I: Iterator<Item = T> + SourceIter<Source: AsVecIntoIter> + InPlaceIterableMarker,
|
||||
{
|
||||
default fn from_iter(mut iterator: I) -> Self {
|
||||
// See "Layout constraints" section in the module documentation. We rely on const
|
||||
// optimization here since these conditions currently cannot be expressed as trait bounds
|
||||
if mem::size_of::<T>() == 0
|
||||
|| mem::size_of::<T>()
|
||||
!= mem::size_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
|
||||
!= mem::size_of::<<<I as SourceIter>::Source as AsVecIntoIter>::Item>()
|
||||
|| mem::align_of::<T>()
|
||||
!= mem::align_of::<<<I as SourceIter>::Source as AsIntoIter>::Item>()
|
||||
!= mem::align_of::<<<I as SourceIter>::Source as AsVecIntoIter>::Item>()
|
||||
{
|
||||
// fallback to more generic implementations
|
||||
return SpecFromIterNested::from_iter(iterator);
|
||||
|
@ -289,7 +289,7 @@ where
|
|||
/// In-place iteration relies on implementation details of `vec::IntoIter`, most importantly that
|
||||
/// it does not create references to the whole allocation during iteration, only raw pointers
|
||||
#[rustc_specialization_trait]
|
||||
pub(crate) unsafe trait AsIntoIter {
|
||||
pub(crate) unsafe trait AsVecIntoIter {
|
||||
type Item;
|
||||
fn as_into_iter(&mut self) -> &mut super::IntoIter<Self::Item>;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#[cfg(not(no_global_oom_handling))]
|
||||
use super::AsIntoIter;
|
||||
use super::AsVecIntoIter;
|
||||
use crate::alloc::{Allocator, Global};
|
||||
use crate::raw_vec::RawVec;
|
||||
use core::fmt;
|
||||
|
@ -346,7 +346,7 @@ unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> {
|
|||
}
|
||||
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
unsafe impl<T> AsIntoIter for IntoIter<T> {
|
||||
unsafe impl<T> AsVecIntoIter for IntoIter<T> {
|
||||
type Item = T;
|
||||
|
||||
fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item> {
|
||||
|
|
|
@ -96,7 +96,7 @@ mod drain;
|
|||
mod cow;
|
||||
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
pub(crate) use self::in_place_collect::AsIntoIter;
|
||||
pub(crate) use self::in_place_collect::AsVecIntoIter;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::into_iter::IntoIter;
|
||||
|
||||
|
|
Loading…
Add table
Reference in a new issue