Skip to content

Commit 1735e6e

Browse files
committed
rustfmt
1 parent b6f4bc0 commit 1735e6e

File tree

2 files changed

+27
-22
lines changed

2 files changed

+27
-22
lines changed

src/indexmap.rs

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -203,7 +203,7 @@ where
203203
unsafe { self.entries.push_unchecked(Bucket { hash, key, value }) };
204204
return Insert::Success(Inserted {
205205
index: self.insert_phase_2(probe, Pos::new(index, hash)),
206-
old_value: None
206+
old_value: None,
207207
});
208208
} else if entry_hash == hash && unsafe { self.entries.get_unchecked(i).key == key }
209209
{
@@ -217,7 +217,7 @@ where
217217
}
218218
} else {
219219
if self.entries.is_full() {
220-
return Insert::Full((key, value))
220+
return Insert::Full((key, value));
221221
}
222222
// empty bucket, insert here
223223
let index = self.entries.len();
@@ -321,7 +321,7 @@ pub enum Entry<'a, K, V, const N: usize> {
321321
/// The entry corresponding to the key `K` exists in the map
322322
Occupied(OccupiedEntry<'a, K, V, N>),
323323
/// The entry corresponding to the key `K` does not exist in the map
324-
Vacant(VacantEntry<'a, K, V, N>)
324+
Vacant(VacantEntry<'a, K, V, N>),
325325
}
326326

327327
/// An occupied entry which can be manipulated
@@ -332,8 +332,10 @@ pub struct OccupiedEntry<'a, K, V, const N: usize> {
332332
core: &'a mut CoreMap<K, V, N>,
333333
}
334334

335-
impl<'a, K, V, const N: usize> OccupiedEntry<'a, K, V, N> where K: Eq + Hash {
336-
335+
impl<'a, K, V, const N: usize> OccupiedEntry<'a, K, V, N>
336+
where
337+
K: Eq + Hash,
338+
{
337339
/// Gets a reference to the key that this entity corresponds to
338340
pub fn key(&self) -> &K {
339341
&self.key
@@ -348,30 +350,33 @@ impl<'a, K, V, const N: usize> OccupiedEntry<'a, K, V, N> where K: Eq + Hash {
348350
pub fn get(&self) -> &V {
349351
// SAFETY: Already checked existence at instantiation and the only mutable reference
350352
// to the map is internally held.
351-
unsafe {
352-
&self.core.entries.get_unchecked(self.pos).value
353-
}
353+
unsafe { &self.core.entries.get_unchecked(self.pos).value }
354354
}
355355

356356
/// Gets a mutable reference to the value associated with this entry
357357
pub fn get_mut(&mut self) -> &mut V {
358358
// SAFETY: Already checked existence at instantiation and the only mutable reference
359359
// to the map is internally held.
360-
unsafe {&mut self.core.entries.get_unchecked_mut(self.pos).value}
360+
unsafe { &mut self.core.entries.get_unchecked_mut(self.pos).value }
361361
}
362362

363363
/// Consumes this entry and yields a reference to the underlying value
364364
pub fn into_mut(self) -> &'a mut V {
365365
// SAFETY: Already checked existence at instantiation and the only mutable reference
366366
// to the map is internally held.
367-
unsafe {&mut self.core.entries.get_unchecked_mut(self.pos).value}
367+
unsafe { &mut self.core.entries.get_unchecked_mut(self.pos).value }
368368
}
369369

370370
/// Overwrites the underlying map's value with this entry's value
371371
pub fn insert(self, value: V) -> V {
372372
// SAFETY: Already checked existence at instantiation and the only mutable reference
373373
// to the map is internally held.
374-
unsafe { mem::replace(&mut self.core.entries.get_unchecked_mut(self.pos).value, value)}
374+
unsafe {
375+
mem::replace(
376+
&mut self.core.entries.get_unchecked_mut(self.pos).value,
377+
value,
378+
)
379+
}
375380
}
376381

377382
/// Removes this entry from the map and yields its value
@@ -386,8 +391,10 @@ pub struct VacantEntry<'a, K, V, const N: usize> {
386391
hash_val: HashValue,
387392
core: &'a mut CoreMap<K, V, N>,
388393
}
389-
impl<'a, K, V, const N: usize> VacantEntry<'a, K, V, N> where K: Eq + Hash {
390-
394+
impl<'a, K, V, const N: usize> VacantEntry<'a, K, V, N>
395+
where
396+
K: Eq + Hash,
397+
{
391398
/// Get the key associated with this entry
392399
pub fn key(&self) -> &K {
393400
&self.key
@@ -416,7 +423,6 @@ impl<'a, K, V, const N: usize> VacantEntry<'a, K, V, N> where K: Eq + Hash {
416423
}
417424
}
418425
}
419-
420426
}
421427

422428
/// Fixed capacity [`IndexMap`](https://docs.rs/indexmap/1/indexmap/map/struct.IndexMap.html)
@@ -598,7 +604,6 @@ where
598604
}
599605
}
600606

601-
602607
/// Returns an entry for the corresponding key
603608
/// ```
604609
/// use heapless::FnvIndexMap;
@@ -621,13 +626,13 @@ where
621626
key,
622627
probe,
623628
pos,
624-
core: &mut self.core
629+
core: &mut self.core,
625630
})
626631
} else {
627632
Entry::Vacant(VacantEntry {
628633
key,
629634
hash_val,
630-
core: &mut self.core
635+
core: &mut self.core,
631636
})
632637
}
633638
}
@@ -794,7 +799,7 @@ where
794799
let hash = hash_with(&key, &self.build_hasher);
795800
match self.core.insert(hash, key, value) {
796801
Insert::Success(inserted) => Ok(inserted.old_value),
797-
Insert::Full((k, v)) => Err((k, v))
802+
Insert::Full((k, v)) => Err((k, v)),
798803
}
799804
}
800805

@@ -1082,9 +1087,9 @@ where
10821087

10831088
#[cfg(test)]
10841089
mod tests {
1090+
use crate::indexmap::Entry;
10851091
use crate::FnvIndexMap;
10861092
use core::mem;
1087-
use crate::indexmap::Entry;
10881093

10891094
#[test]
10901095
fn size() {
@@ -1239,7 +1244,7 @@ mod tests {
12391244
match entry {
12401245
Entry::Occupied(o) => {
12411246
assert_eq!((key, value), o.remove_entry());
1242-
},
1247+
}
12431248
Entry::Vacant(_) => {
12441249
panic!("Entry not found")
12451250
}
@@ -1258,7 +1263,7 @@ mod tests {
12581263
match entry {
12591264
Entry::Occupied(o) => {
12601265
assert_eq!(value, o.remove());
1261-
},
1266+
}
12621267
Entry::Vacant(_) => {
12631268
panic!("Entry not found");
12641269
}

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@
7777
pub use binary_heap::BinaryHeap;
7878
pub use deque::Deque;
7979
pub use histbuf::{HistoryBuffer, OldestOrdered};
80-
pub use indexmap::{Bucket, FnvIndexMap, IndexMap, Pos, Entry, OccupiedEntry, VacantEntry};
80+
pub use indexmap::{Bucket, Entry, FnvIndexMap, IndexMap, OccupiedEntry, Pos, VacantEntry};
8181
pub use indexset::{FnvIndexSet, IndexSet};
8282
pub use linear_map::LinearMap;
8383
#[cfg(all(has_cas, feature = "cas"))]

0 commit comments

Comments
 (0)