Replace unsafe code with safer variant
cynecx opened this issue · comments
cynecx commented
I've been digging in some of the internals of shred with emphasis on unsafe
code and I've noticed this particular method:
Lines 91 to 112 in c1bfcda
I can't see why one would use unsafe
here, if I am not missing anything crucial here, this could be replaced with a completely safe alternative:
pub fn map<U, F>(self, f: F) -> Ref<'a, U>
where
F: FnOnce(&T) -> &U,
U: ?Sized,
{
let val = Ref {
flag: self.flag,
value: f(self.value),
};
std::mem::forget(self);
val
}