mirror of
https://github.com/openharmony/third_party_rust_tinyvec.git
synced 2026-07-19 14:23:33 -04:00
Merge pull request #54 from Nemo157/intoiter-debug
impl Debug for {Tiny,Array}VecIterator
This commit is contained in:
@@ -814,6 +814,14 @@ pub struct ArrayVecIterator<A: Array> {
|
||||
len: usize,
|
||||
data: A,
|
||||
}
|
||||
|
||||
impl<A: Array> ArrayVecIterator<A> {
|
||||
/// Returns the remaining items of this iterator as a slice.
|
||||
pub fn as_slice(&self) -> &[A::Item] {
|
||||
&self.data.as_slice()[self.base..self.len]
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> Iterator for ArrayVecIterator<A> {
|
||||
type Item = A::Item;
|
||||
#[inline]
|
||||
@@ -853,6 +861,12 @@ impl<A: Array> Iterator for ArrayVecIterator<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> Debug for ArrayVecIterator<A> where A::Item: Debug {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_tuple("ArrayVecIterator").field(&self.as_slice()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> IntoIterator for ArrayVec<A> {
|
||||
type Item = A::Item;
|
||||
type IntoIter = ArrayVecIterator<A>;
|
||||
|
||||
@@ -715,6 +715,17 @@ pub enum TinyVecIterator<A: Array> {
|
||||
#[allow(missing_docs)]
|
||||
Heap(alloc::vec::IntoIter<A::Item>),
|
||||
}
|
||||
|
||||
impl<A: Array> TinyVecIterator<A> {
|
||||
/// Returns the remaining items of this iterator as a slice.
|
||||
pub fn as_slice(&self) -> &[A::Item] {
|
||||
match self {
|
||||
TinyVecIterator::Inline(a) => a.as_slice(),
|
||||
TinyVecIterator::Heap(v) => v.as_slice(),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> Iterator for TinyVecIterator<A> {
|
||||
type Item = A::Item;
|
||||
#[inline]
|
||||
@@ -755,6 +766,12 @@ impl<A: Array> Iterator for TinyVecIterator<A> {
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> Debug for TinyVecIterator<A> where A::Item: Debug {
|
||||
fn fmt(&self, f: &mut Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_tuple("TinyVecIterator").field(&self.as_slice()).finish()
|
||||
}
|
||||
}
|
||||
|
||||
impl<A: Array> IntoIterator for TinyVec<A> {
|
||||
type Item = A::Item;
|
||||
type IntoIter = TinyVecIterator<A>;
|
||||
|
||||
Reference in New Issue
Block a user