Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
xacrimon committed Jul 11, 2023
1 parent 3b41846 commit 6616a8d
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions src/mapref/entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,12 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> Entry<'a, K, V, S> {
///
/// If you are not interested in the occupied entry,
/// consider [`insert`] as it doesn't need to clone the key.
///
///
/// [`insert`]: Entry::insert
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S> where K: Clone {
pub fn insert_entry(self, value: V) -> OccupiedEntry<'a, K, V, S>
where
K: Clone,
{
match self {
Entry::Occupied(mut entry) => {
entry.insert(value);
Expand Down Expand Up @@ -145,7 +148,10 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> VacantEntry<'a, K, V, S> {
}

/// Sets the value of the entry with the VacantEntry’s key, and returns an OccupiedEntry.
pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, S> where K: Clone {
pub fn insert_entry(mut self, value: V) -> OccupiedEntry<'a, K, V, S>
where
K: Clone,
{
unsafe {
self.shard.insert(self.key.clone(), SharedValue::new(value));

Expand Down Expand Up @@ -230,8 +236,6 @@ impl<'a, K: Eq + Hash, V, S: BuildHasher> OccupiedEntry<'a, K, V, S> {
}
}



#[cfg(test)]
mod tests {
use crate::DashMap;
Expand All @@ -245,7 +249,7 @@ mod tests {
let entry = map.entry(1);

assert!(matches!(entry, Entry::Vacant(_)));

let entry = entry.insert_entry(2);

assert_eq!(*entry.get(), 2);
Expand All @@ -264,7 +268,7 @@ mod tests {
let entry = map.entry(1);

assert!(matches!(&entry, Entry::Occupied(entry) if *entry.get() == 1000));

let entry = entry.insert_entry(2);

assert_eq!(*entry.get(), 2);
Expand All @@ -273,4 +277,4 @@ mod tests {

assert_eq!(*map.get(&1).unwrap(), 2);
}
}
}

0 comments on commit 6616a8d

Please sign in to comment.