aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorDavid LeGare <legare@google.com>2022-03-04 22:56:14 +0000
committerAutomerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com>2022-03-04 22:56:14 +0000
commitb54de970eb3a80b64222362b7e35e8d0ecde7848 (patch)
tree619b140d4e933acdbc6d87f524856c1a682011ad /src
parent2264650fc3626b76a24ec9de8799ef1656508fc1 (diff)
parent4b88bd150c6abd3dbb8710d358e9cba3d94457b0 (diff)
downloadslab-b54de970eb3a80b64222362b7e35e8d0ecde7848.tar.gz
Update slab to 0.4.5 am: 4b88bd150c
Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/slab/+/2005114 Change-Id: I5d8d0579471c30aced0ddef0f29ffaf9dd0f1cf2
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()
}