From 4b88bd150c6abd3dbb8710d358e9cba3d94457b0 Mon Sep 17 00:00:00 2001 From: David LeGare Date: Wed, 2 Mar 2022 16:21:15 +0000 Subject: Update slab to 0.4.5 Test: cd external/rust/crates && atest --host -c Change-Id: I7e7b1c06dd90cf1e342204c2f4827b76c2c96d55 --- .cargo_vcs_info.json | 2 +- Android.bp | 4 ++-- CHANGELOG.md | 6 ++++++ Cargo.toml | 2 +- Cargo.toml.orig | 2 +- METADATA | 10 +++++----- src/lib.rs | 23 ++++++++++++++++++----- 7 files changed, 34 insertions(+), 15 deletions(-) diff --git a/.cargo_vcs_info.json b/.cargo_vcs_info.json index 820133c..90db974 100644 --- a/.cargo_vcs_info.json +++ b/.cargo_vcs_info.json @@ -1,5 +1,5 @@ { "git": { - "sha1": "76d9ca4e0c0313c1eeafa691e11446906e2bb4a7" + "sha1": "c512385b1a70100c8597f0f519390c80e90c9529" } } diff --git a/Android.bp b/Android.bp index 261e728..6c87c6e 100644 --- a/Android.bp +++ b/Android.bp @@ -23,7 +23,7 @@ rust_library { host_supported: true, crate_name: "slab", cargo_env_compat: true, - cargo_pkg_version: "0.4.4", + cargo_pkg_version: "0.4.5", srcs: ["src/lib.rs"], edition: "2018", features: [ @@ -44,7 +44,7 @@ rust_test { host_supported: true, crate_name: "slab", cargo_env_compat: true, - cargo_pkg_version: "0.4.4", + cargo_pkg_version: "0.4.5", srcs: ["tests/slab.rs"], test_suites: ["general-tests"], auto_gen_config: true, diff --git a/CHANGELOG.md b/CHANGELOG.md index 5b5edd8..501a25c 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,3 +1,9 @@ +# 0.4.5 (October 13, 2021) + + * Add alternate debug output for listing items in the slab (#108) + * Fix typo in debug output of IntoIter (#109) + * Impl 'Clone' for 'Iter' (#110) + # 0.4.4 (August 06, 2021) * Fix panic in `FromIterator` impl (#102) diff --git a/Cargo.toml b/Cargo.toml index 218805d..e1cca93 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -12,7 +12,7 @@ [package] edition = "2018" name = "slab" -version = "0.4.4" +version = "0.4.5" authors = ["Carl Lerche "] exclude = ["/.*"] description = "Pre-allocated storage for a uniform data type" diff --git a/Cargo.toml.orig b/Cargo.toml.orig index b017ada..bc25be8 100644 --- a/Cargo.toml.orig +++ b/Cargo.toml.orig @@ -6,7 +6,7 @@ name = "slab" # - README.md # - Update CHANGELOG.md # - Create git tag -version = "0.4.4" +version = "0.4.5" authors = ["Carl Lerche "] edition = "2018" license = "MIT" diff --git a/METADATA b/METADATA index b037efe..6ca4640 100644 --- a/METADATA +++ b/METADATA @@ -7,13 +7,13 @@ third_party { } url { type: ARCHIVE - value: "https://static.crates.io/crates/slab/slab-0.4.4.crate" + value: "https://static.crates.io/crates/slab/slab-0.4.5.crate" } - version: "0.4.4" + version: "0.4.5" license_type: NOTICE last_upgrade_date { - year: 2021 - month: 8 - day: 9 + year: 2022 + month: 3 + day: 1 } } 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>>, @@ -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() } -- cgit v1.2.3