|
12 | 12 | use super::raw::RawTableEntry;
|
13 | 13 | use super::{get_hash, IndexMapCore};
|
14 | 14 | use crate::{Equivalent, HashValue, IndexMap};
|
| 15 | +use core::fmt; |
15 | 16 | use core::hash::{BuildHasher, Hash, Hasher};
|
16 | 17 | use core::marker::PhantomData;
|
17 | 18 | use core::mem;
|
@@ -181,6 +182,12 @@ pub struct RawEntryBuilder<'a, K, V, S> {
|
181 | 182 | map: &'a IndexMap<K, V, S>,
|
182 | 183 | }
|
183 | 184 |
|
| 185 | +impl<K, V, S> fmt::Debug for RawEntryBuilder<'_, K, V, S> { |
| 186 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 187 | + f.debug_struct("RawEntryBuilder").finish_non_exhaustive() |
| 188 | + } |
| 189 | +} |
| 190 | + |
184 | 191 | impl<'a, K, V, S> RawEntryBuilder<'a, K, V, S> {
|
185 | 192 | /// Access an entry by key.
|
186 | 193 | pub fn from_key<Q: ?Sized>(self, key: &Q) -> Option<(&'a K, &'a V)>
|
@@ -222,6 +229,12 @@ pub struct RawEntryBuilderMut<'a, K, V, S> {
|
222 | 229 | map: &'a mut IndexMap<K, V, S>,
|
223 | 230 | }
|
224 | 231 |
|
| 232 | +impl<K, V, S> fmt::Debug for RawEntryBuilderMut<'_, K, V, S> { |
| 233 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 234 | + f.debug_struct("RawEntryBuilderMut").finish_non_exhaustive() |
| 235 | + } |
| 236 | +} |
| 237 | + |
225 | 238 | impl<'a, K, V, S> RawEntryBuilderMut<'a, K, V, S> {
|
226 | 239 | /// Access an entry by key.
|
227 | 240 | pub fn from_key<Q: ?Sized>(self, key: &Q) -> RawEntryMut<'a, K, V, S>
|
@@ -269,6 +282,17 @@ pub enum RawEntryMut<'a, K, V, S> {
|
269 | 282 | Vacant(RawVacantEntryMut<'a, K, V, S>),
|
270 | 283 | }
|
271 | 284 |
|
| 285 | +impl<K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for RawEntryMut<'_, K, V, S> { |
| 286 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 287 | + let mut tuple = f.debug_tuple("RawEntryMut"); |
| 288 | + match self { |
| 289 | + Self::Vacant(v) => tuple.field(v), |
| 290 | + Self::Occupied(o) => tuple.field(o), |
| 291 | + }; |
| 292 | + tuple.finish() |
| 293 | + } |
| 294 | +} |
| 295 | + |
272 | 296 | impl<'a, K, V, S> RawEntryMut<'a, K, V, S> {
|
273 | 297 | /// Inserts the given default key and value in the entry if it is vacant and returns mutable
|
274 | 298 | /// references to them. Otherwise mutable references to an already existent pair are returned.
|
@@ -320,6 +344,15 @@ pub struct RawOccupiedEntryMut<'a, K, V, S> {
|
320 | 344 | hash_builder: PhantomData<&'a S>,
|
321 | 345 | }
|
322 | 346 |
|
| 347 | +impl<K: fmt::Debug, V: fmt::Debug, S> fmt::Debug for RawOccupiedEntryMut<'_, K, V, S> { |
| 348 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 349 | + f.debug_struct("RawOccupiedEntryMut") |
| 350 | + .field("key", self.key()) |
| 351 | + .field("value", self.get()) |
| 352 | + .finish_non_exhaustive() |
| 353 | + } |
| 354 | +} |
| 355 | + |
323 | 356 | impl<'a, K, V, S> RawOccupiedEntryMut<'a, K, V, S> {
|
324 | 357 | /// Return the index of the key-value pair
|
325 | 358 | #[inline]
|
@@ -478,6 +511,12 @@ pub struct RawVacantEntryMut<'a, K, V, S> {
|
478 | 511 | hash_builder: &'a S,
|
479 | 512 | }
|
480 | 513 |
|
| 514 | +impl<K, V, S> fmt::Debug for RawVacantEntryMut<'_, K, V, S> { |
| 515 | + fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { |
| 516 | + f.debug_struct("RawVacantEntryMut").finish_non_exhaustive() |
| 517 | + } |
| 518 | +} |
| 519 | + |
481 | 520 | impl<'a, K, V, S> RawVacantEntryMut<'a, K, V, S> {
|
482 | 521 | /// Return the index where a key-value pair may be inserted.
|
483 | 522 | pub fn index(&self) -> usize {
|
|
0 commit comments