mirror of
https://github.com/rust-lang/rust.git
synced 2024-11-01 06:51:58 +00:00
move AsIntoIter helper trait and mark it as unsafe
This commit is contained in:
parent
47a7a07a8b
commit
79b43b35be
@ -1416,7 +1416,7 @@ unsafe impl<T> SourceIter for IntoIter<T> {
|
||||
#[doc(hidden)]
|
||||
unsafe impl<I> InPlaceIterable for IntoIter<I> {}
|
||||
|
||||
impl<I> AsIntoIter for IntoIter<I> {
|
||||
unsafe impl<I> AsIntoIter for IntoIter<I> {
|
||||
type Item = I;
|
||||
|
||||
fn as_into_iter(&mut self) -> &mut vec::IntoIter<Self::Item> {
|
||||
|
@ -2,7 +2,7 @@ use core::iter::{InPlaceIterable, SourceIter, TrustedRandomAccessNoCoerce};
|
||||
use core::mem::{self, ManuallyDrop};
|
||||
use core::ptr::{self};
|
||||
|
||||
use super::{AsIntoIter, InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec};
|
||||
use super::{InPlaceDrop, SpecFromIter, SpecFromIterNested, Vec};
|
||||
|
||||
/// Specialization marker for collecting an iterator pipeline into a Vec while reusing the
|
||||
/// source allocation, i.e. executing the pipeline in place.
|
||||
@ -154,3 +154,10 @@ where
|
||||
len
|
||||
}
|
||||
}
|
||||
|
||||
// internal helper trait for in-place iteration specialization.
|
||||
#[rustc_specialization_trait]
|
||||
pub(crate) unsafe trait AsIntoIter {
|
||||
type Item;
|
||||
fn as_into_iter(&mut self) -> &mut super::IntoIter<Self::Item>;
|
||||
}
|
||||
|
@ -1,3 +1,5 @@
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
use super::AsIntoIter;
|
||||
use crate::alloc::{Allocator, Global};
|
||||
use crate::raw_vec::RawVec;
|
||||
use core::fmt;
|
||||
@ -338,14 +340,8 @@ unsafe impl<T, A: Allocator> SourceIter for IntoIter<T, A> {
|
||||
}
|
||||
}
|
||||
|
||||
// internal helper trait for in-place iteration specialization.
|
||||
#[rustc_specialization_trait]
|
||||
pub(crate) trait AsIntoIter {
|
||||
type Item;
|
||||
fn as_into_iter(&mut self) -> &mut IntoIter<Self::Item>;
|
||||
}
|
||||
|
||||
impl<T> AsIntoIter for IntoIter<T> {
|
||||
#[cfg(not(no_global_oom_handling))]
|
||||
unsafe impl<T> AsIntoIter 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::into_iter::AsIntoIter;
|
||||
pub(crate) use self::in_place_collect::AsIntoIter;
|
||||
#[stable(feature = "rust1", since = "1.0.0")]
|
||||
pub use self::into_iter::IntoIter;
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user