aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid LeGare <legare@google.com>2022-03-02 16:21:15 +0000
committerDavid LeGare <legare@google.com>2022-03-02 16:21:15 +0000
commit4b88bd150c6abd3dbb8710d358e9cba3d94457b0 (patch)
tree619b140d4e933acdbc6d87f524856c1a682011ad /src
parente36c5d1b0e4126406130c1275974291c8a2d5b9b (diff)
downloadslab-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.rs23
1 files changed, 18 insertions, 5 deletions
diff --git a/src/lib.rs b/src/lib.rs
index d277547..271c1db 100644
--- a/src/lib.rs
+++ b/src/lib.rs
@@ -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()
}