Skip to content

Commit 844d5aa

Browse files
committed
Suggestions from PR review.
H/T @ajguerrer & @Mephistophiles
1 parent ea1fae9 commit 844d5aa

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

evmap/src/read.rs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -224,7 +224,11 @@ where
224224
Map: FnMut(&K, &Values<V, S>) -> Target,
225225
Collector: FromIterator<Target>,
226226
{
227-
Collector::from_iter(self.enter().iter().flatten().map(|(k, v)| f(k, v)))
227+
self.enter()
228+
.iter()
229+
.flatten()
230+
.map(|(k, v)| f(k, v))
231+
.collect()
228232
}
229233
}
230234

evmap/src/write.rs

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -331,7 +331,9 @@ where
331331
// shallow copy of each value.
332332
//
333333
// Safety: ManuallyDrop<T> has the same layout as T.
334-
let inner: &mut Inner<K, ManuallyDrop<V>, M, S> = unsafe { mem::transmute(self) };
334+
let inner = unsafe {
335+
&mut *(self as *mut Inner<K, V, M, S> as *mut Inner<K, ManuallyDrop<V>, M, S>)
336+
};
335337
let hasher = other.data.hasher();
336338
match *op {
337339
Operation::Replace(ref key, ref mut value) => {
@@ -535,7 +537,8 @@ where
535537
// any elements since its values are kept as ManuallyDrop:
536538
//
537539
// Safety: ManuallyDrop<T> has the same layout as T.
538-
let inner: Box<Inner<K, ManuallyDrop<V>, M, S>> = unsafe { mem::transmute(self) };
540+
let inner =
541+
unsafe { Box::from_raw(Box::into_raw(self) as *mut Inner<K, ManuallyDrop<V>, M, S>) };
539542
drop(inner);
540543
}
541544
}

0 commit comments

Comments
 (0)