2 use core::iter::{FusedIterator, TrustedLen};
4 use crate::alloc::{Allocator, Global};
8 /// An owning iterator over the elements of a `VecDeque`.
10 /// This `struct` is created by the [`into_iter`] method on [`VecDeque`]
11 /// (provided by the [`IntoIterator`] trait). See its documentation for more.
13 /// [`into_iter`]: VecDeque::into_iter
14 /// [`IntoIterator`]: core::iter::IntoIterator
16 #[stable(feature = "rust1", since = "1.0.0")]
19 #[unstable(feature = "allocator_api", issue = "32838")] A: Allocator = Global,
21 inner: VecDeque<T, A>,
24 impl<T, A: Allocator> IntoIter<T, A> {
25 pub(super) fn new(inner: VecDeque<T, A>) -> Self {
30 #[stable(feature = "collection_debug", since = "1.17.0")]
31 impl<T: fmt::Debug, A: Allocator> fmt::Debug for IntoIter<T, A> {
32 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
33 f.debug_tuple("IntoIter").field(&self.inner).finish()
37 #[stable(feature = "rust1", since = "1.0.0")]
38 impl<T, A: Allocator> Iterator for IntoIter<T, A> {
42 fn next(&mut self) -> Option<T> {
43 self.inner.pop_front()
47 fn size_hint(&self) -> (usize, Option<usize>) {
48 let len = self.inner.len();
53 #[stable(feature = "rust1", since = "1.0.0")]
54 impl<T, A: Allocator> DoubleEndedIterator for IntoIter<T, A> {
56 fn next_back(&mut self) -> Option<T> {
61 #[stable(feature = "rust1", since = "1.0.0")]
62 impl<T, A: Allocator> ExactSizeIterator for IntoIter<T, A> {
63 fn is_empty(&self) -> bool {
68 #[stable(feature = "fused", since = "1.26.0")]
69 impl<T, A: Allocator> FusedIterator for IntoIter<T, A> {}
71 #[unstable(feature = "trusted_len", issue = "37572")]
72 unsafe impl<T, A: Allocator> TrustedLen for IntoIter<T, A> {}