halfbrown/
raw_entry.rs

1// based on / take from <https://github.com/rust-lang/hashbrown/blob/62a1ae24d4678fcbf777bef6b205fadeecb781d9/src/map.rs>
2
3use super::{fmt, hashbrown, Borrow, BuildHasher, Debug, Hash};
4use crate::vecmap;
5use hashbrown::hash_map;
6/*
7use std::fmt::{self, Debug};
8use std::mem;
9*/
10
11/// A builder for computing where in a [`HashMap`] a key-value pair would be stored.
12///
13/// See the [`HashMap::raw_entry_mut`] docs for usage examples.
14///
15/// [`HashMap::raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
16pub struct RawEntryBuilderMut<'map, K, V, const N: usize, S>(
17    RawEntryBuilderMutInt<'map, K, V, N, S>,
18);
19
20impl<'map, K, V, const N: usize, S> From<hash_map::RawEntryBuilderMut<'map, K, V, S>>
21    for RawEntryBuilderMut<'map, K, V, N, S>
22{
23    fn from(m: hash_map::RawEntryBuilderMut<'map, K, V, S>) -> Self {
24        Self(RawEntryBuilderMutInt::Map(m))
25    }
26}
27
28impl<'map, K, V, const N: usize, S> From<vecmap::RawEntryBuilderMut<'map, K, V, N, S>>
29    for RawEntryBuilderMut<'map, K, V, N, S>
30where
31    S: BuildHasher,
32{
33    fn from(m: vecmap::RawEntryBuilderMut<'map, K, V, N, S>) -> Self {
34        Self(RawEntryBuilderMutInt::Vec(m))
35    }
36}
37enum RawEntryBuilderMutInt<'map, K, V, const N: usize, S> {
38    Vec(vecmap::RawEntryBuilderMut<'map, K, V, N, S>),
39    Map(hash_map::RawEntryBuilderMut<'map, K, V, S>),
40}
41
42/// A view into a single entry in a map, which may either be vacant or occupied.
43///
44/// This is a lower-level version of [`Entry`].
45///
46/// This `enum` is constructed through the [`raw_entry_mut`] method on [`HashMap`],
47/// then calling one of the methods of that [`RawEntryBuilderMut`].
48///
49/// [`HashMap`]: struct.HashMap.html
50/// [`Entry`]: enum.Entry.html
51/// [`raw_entry_mut`]: struct.HashMap.html#method.raw_entry_mut
52/// [`RawEntryBuilderMut`]: struct.RawEntryBuilderMut.html
53pub enum RawEntryMut<'map, K, V, const N: usize, S> {
54    /// An occupied entry.
55    Occupied(RawOccupiedEntryMut<'map, K, V, N, S>),
56    /// A vacant entry.
57    Vacant(RawVacantEntryMut<'map, K, V, N, S>),
58}
59
60impl<'map, K, V, const N: usize, S> From<vecmap::RawEntryMut<'map, K, V, N, S>>
61    for RawEntryMut<'map, K, V, N, S>
62{
63    fn from(e: vecmap::RawEntryMut<'map, K, V, N, S>) -> Self {
64        match e {
65            vecmap::RawEntryMut::Occupied(o) => Self::Occupied(o.into()),
66            vecmap::RawEntryMut::Vacant(v) => Self::Vacant(v.into()),
67        }
68    }
69}
70
71impl<'map, K, V, const N: usize, S> From<hash_map::RawEntryMut<'map, K, V, S>>
72    for RawEntryMut<'map, K, V, N, S>
73{
74    fn from(e: hash_map::RawEntryMut<'map, K, V, S>) -> Self {
75        match e {
76            hash_map::RawEntryMut::Occupied(o) => Self::Occupied(o.into()),
77            hash_map::RawEntryMut::Vacant(v) => Self::Vacant(v.into()),
78        }
79    }
80}
81
82/// A view into an occupied entry in a `HashMap`.
83/// It is part of the [`RawEntryMut`] enum.
84///
85/// [`RawEntryMut`]: enum.RawEntryMut.html
86pub struct RawOccupiedEntryMut<'map, K, V, const N: usize, S>(
87    RawOccupiedEntryMutInt<'map, K, V, N, S>,
88);
89
90impl<'map, K, V, const N: usize, S> From<vecmap::RawOccupiedEntryMut<'map, K, V, N, S>>
91    for RawOccupiedEntryMut<'map, K, V, N, S>
92{
93    fn from(m: vecmap::RawOccupiedEntryMut<'map, K, V, N, S>) -> Self {
94        Self(RawOccupiedEntryMutInt::Vec(m))
95    }
96}
97
98impl<'map, K, V, const N: usize, S> From<hash_map::RawOccupiedEntryMut<'map, K, V, S>>
99    for RawOccupiedEntryMut<'map, K, V, N, S>
100{
101    fn from(m: hash_map::RawOccupiedEntryMut<'map, K, V, S>) -> Self {
102        Self(RawOccupiedEntryMutInt::Map(m))
103    }
104}
105
106unsafe impl<K, V, const N: usize, S> Send for RawOccupiedEntryMut<'_, K, V, N, S>
107where
108    K: Send,
109    V: Send,
110    S: Send,
111{
112}
113
114unsafe impl<K, V, const N: usize, S> Sync for RawOccupiedEntryMut<'_, K, V, N, S>
115where
116    K: Sync,
117    V: Sync,
118    S: Sync,
119{
120}
121
122enum RawOccupiedEntryMutInt<'map, K, V, const N: usize, S> {
123    Vec(vecmap::RawOccupiedEntryMut<'map, K, V, N, S>),
124    Map(hash_map::RawOccupiedEntryMut<'map, K, V, S>),
125}
126
127unsafe impl<K, V, const N: usize, S> Send for RawOccupiedEntryMutInt<'_, K, V, N, S>
128where
129    K: Send,
130    V: Send,
131    S: Send,
132{
133}
134unsafe impl<K, V, const N: usize, S> Sync for RawOccupiedEntryMutInt<'_, K, V, N, S>
135where
136    K: Sync,
137    V: Sync,
138    S: Sync,
139{
140}
141
142/// A view into a vacant entry in a `HashMap`.
143/// It is part of the [`RawEntryMut`] enum.
144///
145/// [`RawEntryMut`]: enum.RawEntryMut.html
146pub struct RawVacantEntryMut<'map, K, V, const N: usize, S>(RawVacantEntryMutInt<'map, K, V, N, S>);
147
148impl<'map, K, V, const N: usize, S> From<vecmap::RawVacantEntryMut<'map, K, V, N, S>>
149    for RawVacantEntryMut<'map, K, V, N, S>
150{
151    fn from(m: vecmap::RawVacantEntryMut<'map, K, V, N, S>) -> Self {
152        Self(RawVacantEntryMutInt::Vec(m))
153    }
154}
155
156impl<'map, K, V, const N: usize, S> From<hash_map::RawVacantEntryMut<'map, K, V, S>>
157    for RawVacantEntryMut<'map, K, V, N, S>
158{
159    fn from(m: hash_map::RawVacantEntryMut<'map, K, V, S>) -> Self {
160        Self(RawVacantEntryMutInt::Map(m))
161    }
162}
163
164enum RawVacantEntryMutInt<'map, K, V, const N: usize, S> {
165    Vec(vecmap::RawVacantEntryMut<'map, K, V, N, S>),
166    Map(hash_map::RawVacantEntryMut<'map, K, V, S>),
167}
168
169/// A builder for computing where in a [`HashMap`] a key-value pair would be stored.
170///
171/// See the [`HashMap::raw_entry`] docs for usage examples.
172///
173/// [`HashMap::raw_entry`]: struct.HashMap.html#method.raw_entry
174///
175pub struct RawEntryBuilder<'map, K, V, const N: usize, S>(RawEntryBuilderInt<'map, K, V, N, S>);
176
177impl<'map, K, V, const N: usize, S> From<hash_map::RawEntryBuilder<'map, K, V, S>>
178    for RawEntryBuilder<'map, K, V, N, S>
179{
180    fn from(m: hash_map::RawEntryBuilder<'map, K, V, S>) -> Self {
181        Self(RawEntryBuilderInt::Map(m))
182    }
183}
184
185impl<'map, K, V, const N: usize, S> From<vecmap::RawEntryBuilder<'map, K, V, N, S>>
186    for RawEntryBuilder<'map, K, V, N, S>
187{
188    fn from(m: vecmap::RawEntryBuilder<'map, K, V, N, S>) -> Self {
189        Self(RawEntryBuilderInt::Vec(m))
190    }
191}
192
193enum RawEntryBuilderInt<'map, K, V, const N: usize, S> {
194    Vec(vecmap::RawEntryBuilder<'map, K, V, N, S>),
195    Map(hash_map::RawEntryBuilder<'map, K, V, S>),
196}
197
198impl<'map, K, V, const N: usize, S> RawEntryBuilderMut<'map, K, V, N, S>
199where
200    S: BuildHasher,
201{
202    /// Creates a `RawEntryMut` from the given key.
203    #[inline]
204    #[allow(clippy::wrong_self_convention)]
205    pub fn from_key<Q>(self, k: &Q) -> RawEntryMut<'map, K, V, N, S>
206    where
207        K: Borrow<Q>,
208        Q: Hash + Eq + ?Sized,
209    {
210        match self.0 {
211            RawEntryBuilderMutInt::Vec(m) => m.from_key(k).into(),
212            RawEntryBuilderMutInt::Map(m) => m.from_key(k).into(),
213        }
214    }
215
216    /// Creates a `RawEntryMut` from the given key and its hash.
217    #[inline]
218    #[allow(clippy::wrong_self_convention)]
219    pub fn from_key_hashed_nocheck<Q>(self, hash: u64, k: &Q) -> RawEntryMut<'map, K, V, N, S>
220    where
221        K: Borrow<Q>,
222        Q: Eq + ?Sized,
223    {
224        match self.0 {
225            RawEntryBuilderMutInt::Vec(m) => m.from_key_hashed_nocheck(hash, k).into(),
226            RawEntryBuilderMutInt::Map(m) => m.from_key_hashed_nocheck(hash, k).into(),
227        }
228    }
229}
230
231impl<'map, K, V, const N: usize, S> RawEntryBuilderMut<'map, K, V, N, S>
232where
233    S: BuildHasher,
234{
235    /// Creates a `RawEntryMut` from the given hash.
236    #[inline]
237    #[allow(clippy::wrong_self_convention)]
238    pub fn from_hash<F>(self, hash: u64, is_match: F) -> RawEntryMut<'map, K, V, N, S>
239    where
240        for<'b> F: FnMut(&'b K) -> bool,
241    {
242        match self.0 {
243            RawEntryBuilderMutInt::Vec(m) => m.from_hash(hash, is_match).into(),
244            RawEntryBuilderMutInt::Map(m) => m.from_hash(hash, is_match).into(),
245        }
246    }
247}
248
249impl<'map, K, V, const N: usize, S> RawEntryBuilder<'map, K, V, N, S>
250where
251    S: BuildHasher,
252{
253    /// Access an entry by key.
254    #[inline]
255    #[allow(clippy::wrong_self_convention)]
256    pub fn from_key<Q>(self, k: &Q) -> Option<(&'map K, &'map V)>
257    where
258        K: Borrow<Q>,
259        Q: Hash + Eq + ?Sized,
260    {
261        match self.0 {
262            RawEntryBuilderInt::Vec(m) => m.from_key(k),
263            RawEntryBuilderInt::Map(m) => m.from_key(k),
264        }
265    }
266
267    /// Access an entry by a key and its hash.
268    #[inline]
269    #[allow(clippy::wrong_self_convention)]
270    pub fn from_key_hashed_nocheck<Q>(self, hash: u64, k: &Q) -> Option<(&'map K, &'map V)>
271    where
272        K: Borrow<Q>,
273        Q: Hash + Eq + ?Sized,
274    {
275        match self.0 {
276            RawEntryBuilderInt::Vec(m) => m.from_key_hashed_nocheck(hash, k),
277            RawEntryBuilderInt::Map(m) => m.from_key_hashed_nocheck(hash, k),
278        }
279    }
280
281    /// Access an entry by hash.
282    #[inline]
283    #[allow(clippy::wrong_self_convention)]
284    pub fn from_hash<F>(self, hash: u64, is_match: F) -> Option<(&'map K, &'map V)>
285    where
286        F: FnMut(&K) -> bool,
287    {
288        match self.0 {
289            RawEntryBuilderInt::Vec(m) => m.from_hash(hash, is_match),
290            RawEntryBuilderInt::Map(m) => m.from_hash(hash, is_match),
291        }
292    }
293}
294
295impl<'map, K, V, const N: usize, S> RawEntryMut<'map, K, V, N, S>
296where
297    S: BuildHasher,
298{
299    /// Sets the value of the entry, and returns a `RawOccupiedEntryMut`.
300    ///
301    /// # Examples
302    ///
303    /// ```
304    /// use halfbrown::HashMap;
305    ///
306    /// let mut map: HashMap<&str, u32> = HashMap::new();
307    /// let entry = map.raw_entry_mut().from_key("horseyland").insert("horseyland", 37);
308    ///
309    /// assert_eq!(entry.remove_entry(), ("horseyland", 37));
310    /// ```
311    #[inline]
312    pub fn insert(self, key: K, value: V) -> RawOccupiedEntryMut<'map, K, V, N, S>
313    where
314        K: Hash,
315        S: BuildHasher,
316    {
317        match self {
318            RawEntryMut::Occupied(mut entry) => {
319                entry.insert(value);
320                entry
321            }
322            RawEntryMut::Vacant(entry) => {
323                //entry.insert_entry(key, value)
324                match entry.0 {
325                    RawVacantEntryMutInt::Vec(e) => {
326                        vecmap::RawEntryMut::Vacant(e).insert(key, value).into()
327                    }
328                    RawVacantEntryMutInt::Map(e) => {
329                        hash_map::RawEntryMut::Vacant(e).insert(key, value).into()
330                    }
331                }
332            }
333        }
334    }
335
336    /// Ensures a value is in the entry by inserting the default if empty, and returns
337    /// mutable references to the key and value in the entry.
338    ///
339    /// # Examples
340    ///
341    /// ```
342    /// use halfbrown::HashMap;
343    ///
344    /// let mut map: HashMap<&str, u32> = HashMap::new();
345    ///
346    /// map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 3);
347    /// assert_eq!(map["poneyland"], 3);
348    ///
349    /// *map.raw_entry_mut().from_key("poneyland").or_insert("poneyland", 10).1 *= 2;
350    /// assert_eq!(map["poneyland"], 6);
351    /// ```
352    #[inline]
353    pub fn or_insert(self, default_key: K, default_val: V) -> (&'map mut K, &'map mut V)
354    where
355        K: Hash,
356        S: BuildHasher,
357    {
358        match self {
359            RawEntryMut::Occupied(entry) => entry.into_key_value(),
360            RawEntryMut::Vacant(entry) => entry.insert(default_key, default_val),
361        }
362    }
363
364    /// Ensures a value is in the entry by inserting the result of the default function if empty,
365    /// and returns mutable references to the key and value in the entry.
366    ///
367    /// # Examples
368    ///
369    /// ```
370    /// use halfbrown::HashMap;
371    ///
372    /// let mut map: HashMap<&str, String> = HashMap::new();
373    ///
374    /// map.raw_entry_mut().from_key("poneyland").or_insert_with(|| {
375    ///     ("poneyland", "hoho".to_string())
376    /// });
377    ///
378    /// assert_eq!(map["poneyland"], "hoho".to_string());
379    /// ```
380    #[inline]
381    pub fn or_insert_with<F>(self, default: F) -> (&'map mut K, &'map mut V)
382    where
383        F: FnOnce() -> (K, V),
384        K: Hash,
385        S: BuildHasher,
386    {
387        match self {
388            RawEntryMut::Occupied(entry) => entry.into_key_value(),
389            RawEntryMut::Vacant(entry) => {
390                let (k, v) = default();
391                entry.insert(k, v)
392            }
393        }
394    }
395
396    /// Provides in-place mutable access to an occupied entry before any
397    /// potential inserts into the map.
398    ///
399    /// # Examples
400    ///
401    /// ```
402    /// use halfbrown::HashMap;
403    ///
404    /// let mut map: HashMap<&str, u32> = HashMap::new();
405    ///
406    /// map.raw_entry_mut()
407    ///    .from_key("poneyland")
408    ///    .and_modify(|_k, v| { *v += 1 })
409    ///    .or_insert("poneyland", 42);
410    /// assert_eq!(map["poneyland"], 42);
411    ///
412    /// map.raw_entry_mut()
413    ///    .from_key("poneyland")
414    ///    .and_modify(|_k, v| { *v += 1 })
415    ///    .or_insert("poneyland", 0);
416    /// assert_eq!(map["poneyland"], 43);
417    /// ```
418    #[inline]
419    #[must_use]
420    pub fn and_modify<F>(self, f: F) -> Self
421    where
422        F: FnOnce(&mut K, &mut V),
423    {
424        match self {
425            RawEntryMut::Occupied(mut entry) => {
426                {
427                    let (k, v) = entry.get_key_value_mut();
428                    f(k, v);
429                }
430                RawEntryMut::Occupied(entry)
431            }
432            RawEntryMut::Vacant(entry) => RawEntryMut::Vacant(entry),
433        }
434    }
435}
436
437impl<'map, K, V, const N: usize, S> RawOccupiedEntryMut<'map, K, V, N, S>
438where
439    S: BuildHasher,
440{
441    /// Gets a reference to the key in the entry.
442    #[inline]
443    #[must_use]
444    pub fn key(&self) -> &K {
445        match &self.0 {
446            RawOccupiedEntryMutInt::Vec(e) => e.key(),
447            RawOccupiedEntryMutInt::Map(e) => e.key(),
448        }
449    }
450
451    /// Gets a mutable reference to the key in the entry.
452    #[inline]
453    pub fn key_mut(&mut self) -> &mut K {
454        match &mut self.0 {
455            RawOccupiedEntryMutInt::Vec(e) => e.key_mut(),
456            RawOccupiedEntryMutInt::Map(e) => e.key_mut(),
457        }
458    }
459
460    /// Converts the entry into a mutable reference to the key in the entry
461    /// with a lifetime bound to the map itself.
462    #[inline]
463    #[must_use]
464    pub fn into_key(self) -> &'map mut K {
465        match self.0 {
466            RawOccupiedEntryMutInt::Vec(e) => e.into_key(),
467            RawOccupiedEntryMutInt::Map(e) => e.into_key(),
468        }
469    }
470
471    /// Gets a reference to the value in the entry.
472    #[inline]
473    #[must_use]
474    pub fn get(&self) -> &V {
475        match &self.0 {
476            RawOccupiedEntryMutInt::Vec(e) => e.get(),
477            RawOccupiedEntryMutInt::Map(e) => e.get(),
478        }
479    }
480
481    /// Converts the `OccupiedEntry` into a mutable reference to the value in the entry
482    /// with a lifetime bound to the map itself.
483    #[inline]
484    #[must_use]
485    pub fn into_mut(self) -> &'map mut V {
486        match self.0 {
487            RawOccupiedEntryMutInt::Vec(e) => e.into_mut(),
488            RawOccupiedEntryMutInt::Map(e) => e.into_mut(),
489        }
490    }
491
492    /// Gets a mutable reference to the value in the entry.
493    #[inline]
494    pub fn get_mut(&mut self) -> &mut V {
495        match &mut self.0 {
496            RawOccupiedEntryMutInt::Vec(e) => e.get_mut(),
497            RawOccupiedEntryMutInt::Map(e) => e.get_mut(),
498        }
499    }
500
501    /// Gets a reference to the key and value in the entry.
502    #[inline]
503    pub fn get_key_value(&mut self) -> (&K, &V) {
504        match &mut self.0 {
505            RawOccupiedEntryMutInt::Vec(e) => e.get_key_value(),
506            RawOccupiedEntryMutInt::Map(e) => e.get_key_value(),
507        }
508    }
509
510    /// Gets a mutable reference to the key and value in the entry.
511    #[inline]
512    pub fn get_key_value_mut(&mut self) -> (&mut K, &mut V) {
513        match &mut self.0 {
514            RawOccupiedEntryMutInt::Vec(e) => e.get_key_value_mut(),
515            RawOccupiedEntryMutInt::Map(e) => e.get_key_value_mut(),
516        }
517    }
518
519    /// Converts the `OccupiedEntry` into a mutable reference to the key and value in the entry
520    /// with a lifetime bound to the map itself.
521    #[inline]
522    #[must_use]
523    pub fn into_key_value(self) -> (&'map mut K, &'map mut V) {
524        match self.0 {
525            RawOccupiedEntryMutInt::Vec(e) => e.into_key_value(),
526            RawOccupiedEntryMutInt::Map(e) => e.into_key_value(),
527        }
528    }
529
530    /// Sets the value of the entry, and returns the entry's old value.
531    #[inline]
532    pub fn insert(&mut self, value: V) -> V {
533        match &mut self.0 {
534            RawOccupiedEntryMutInt::Vec(e) => e.insert(value),
535            RawOccupiedEntryMutInt::Map(e) => e.insert(value),
536        }
537    }
538
539    /// Sets the value of the entry, and returns the entry's old value.
540    #[inline]
541    pub fn insert_key(&mut self, key: K) -> K {
542        match &mut self.0 {
543            RawOccupiedEntryMutInt::Vec(e) => e.insert_key(key),
544            RawOccupiedEntryMutInt::Map(e) => e.insert_key(key),
545        }
546    }
547
548    /// Takes the value out of the entry, and returns it.
549    #[inline]
550    #[must_use]
551    pub fn remove(self) -> V {
552        match self.0 {
553            RawOccupiedEntryMutInt::Vec(e) => e.remove(),
554            RawOccupiedEntryMutInt::Map(e) => e.remove(),
555        }
556    }
557
558    /// Take the ownership of the key and value from the map.
559    #[inline]
560    #[must_use]
561    pub fn remove_entry(self) -> (K, V) {
562        match self.0 {
563            RawOccupiedEntryMutInt::Vec(e) => e.remove_entry(),
564            RawOccupiedEntryMutInt::Map(e) => e.remove_entry(),
565        }
566    }
567}
568
569impl<'map, K, V, const N: usize, S> RawVacantEntryMut<'map, K, V, N, S>
570where
571    S: BuildHasher,
572{
573    /// Sets the value of the entry with the `VacantEntry`'s key,
574    /// and returns a mutable reference to it.
575    #[inline]
576    pub fn insert(self, key: K, value: V) -> (&'map mut K, &'map mut V)
577    where
578        K: Hash,
579        S: BuildHasher,
580    {
581        match self.0 {
582            RawVacantEntryMutInt::Vec(e) => e.insert(key, value),
583            RawVacantEntryMutInt::Map(e) => e.insert(key, value),
584        }
585    }
586
587    /// Sets the value of the entry with the `VacantEntry`'s key,
588    /// and returns a mutable reference to it.
589    #[inline]
590    #[allow(clippy::shadow_unrelated)]
591    pub fn insert_hashed_nocheck(self, hash: u64, key: K, value: V) -> (&'map mut K, &'map mut V)
592    where
593        K: Hash,
594        S: BuildHasher,
595    {
596        match self.0 {
597            RawVacantEntryMutInt::Vec(e) => e.insert_hashed_nocheck(hash, key, value),
598            RawVacantEntryMutInt::Map(e) => e.insert_hashed_nocheck(hash, key, value),
599        }
600    }
601
602    /// Set the value of an entry with a custom hasher function.
603    #[inline]
604    pub fn insert_with_hasher<H>(
605        self,
606        hash: u64,
607        key: K,
608        value: V,
609        hasher: H,
610    ) -> (&'map mut K, &'map mut V)
611    where
612        S: BuildHasher,
613        H: Fn(&K) -> u64,
614    {
615        match self.0 {
616            RawVacantEntryMutInt::Vec(e) => e.insert_with_hasher(hash, key, value, hasher),
617            RawVacantEntryMutInt::Map(e) => e.insert_with_hasher(hash, key, value, hasher),
618        }
619    }
620}
621
622impl<K, V, const N: usize, S> Debug for RawEntryBuilderMut<'_, K, V, N, S> {
623    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
624        f.debug_struct("RawEntryBuilder").finish()
625    }
626}
627
628impl<K: Debug, V: Debug, const N: usize, S> Debug for RawEntryMut<'_, K, V, N, S>
629where
630    S: BuildHasher,
631{
632    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
633        match *self {
634            RawEntryMut::Vacant(ref v) => f.debug_tuple("RawEntry").field(v).finish(),
635            RawEntryMut::Occupied(ref o) => f.debug_tuple("RawEntry").field(o).finish(),
636        }
637    }
638}
639
640impl<K: Debug, V: Debug, const N: usize, S> Debug for RawOccupiedEntryMut<'_, K, V, N, S>
641where
642    S: BuildHasher,
643{
644    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
645        f.debug_struct("RawOccupiedEntryMut")
646            .field("key", self.key())
647            .field("value", self.get())
648            .finish()
649    }
650}
651
652impl<K, V, const N: usize, S> Debug for RawVacantEntryMut<'_, K, V, N, S> {
653    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
654        f.debug_struct("RawVacantEntryMut").finish()
655    }
656}
657
658impl<K, V, const N: usize, S> Debug for RawEntryBuilder<'_, K, V, N, S> {
659    fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
660        f.debug_struct("RawEntryBuilder").finish()
661    }
662}