Skip to content

Commit

Permalink
rename internal helper trait AsIntoIter to AsVecIntoIter
Browse files Browse the repository at this point in the history
  • Loading branch information
the8472 committed Mar 21, 2022
1 parent a1a602a commit 7549cfa
Show file tree
Hide file tree
Showing 4 changed files with 10 additions and 10 deletions.
4 changes: 2 additions & 2 deletions library/alloc/src/collections/binary_heap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -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> {
Expand Down
10 changes: 5 additions & 5 deletions library/alloc/src/vec/in_place_collect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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);
Expand Down Expand Up @@ -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>;
}
4 changes: 2 additions & 2 deletions library/alloc/src/vec/into_iter.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down Expand Up @@ -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> {
Expand Down
2 changes: 1 addition & 1 deletion library/alloc/src/vec/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down

0 comments on commit 7549cfa

Please sign in to comment.