diff options
author | David LeGare <legare@google.com> | 2022-03-02 16:21:15 +0000 |
---|---|---|
committer | David LeGare <legare@google.com> | 2022-03-02 16:21:15 +0000 |
commit | 4b88bd150c6abd3dbb8710d358e9cba3d94457b0 (patch) | |
tree | 619b140d4e933acdbc6d87f524856c1a682011ad /src | |
parent | e36c5d1b0e4126406130c1275974291c8a2d5b9b (diff) | |
download | slab-4b88bd150c6abd3dbb8710d358e9cba3d94457b0.tar.gz |
Update slab to 0.4.5
Test: cd external/rust/crates && atest --host -c
Change-Id: I7e7b1c06dd90cf1e342204c2f4827b76c2c96d55
Diffstat (limited to 'src')
-rw-r--r-- | src/lib.rs | 23 |
1 files changed, 18 insertions, 5 deletions
@@ -186,6 +186,15 @@ pub struct Iter<'a, T> { len: usize, } +impl<'a, T> Clone for Iter<'a, T> { + fn clone(&self) -> Self { + Self { + entries: self.entries.clone(), + len: self.len, + } + } +} + /// A mutable iterator over the values stored in the `Slab` pub struct IterMut<'a, T> { entries: iter::Enumerate<slice::IterMut<'a, Entry<T>>>, @@ -1253,10 +1262,14 @@ where T: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_struct("Slab") - .field("len", &self.len) - .field("cap", &self.capacity()) - .finish() + if fmt.alternate() { + fmt.debug_map().entries(self.iter()).finish() + } else { + fmt.debug_struct("Slab") + .field("len", &self.len) + .field("cap", &self.capacity()) + .finish() + } } } @@ -1265,7 +1278,7 @@ where T: fmt::Debug, { fn fmt(&self, fmt: &mut fmt::Formatter<'_>) -> fmt::Result { - fmt.debug_struct("Iter") + fmt.debug_struct("IntoIter") .field("remaining", &self.len) .finish() } |