repo: simplify unsafe cast of view reference

This commit is contained in:
Yuya Nishihara 2022-11-05 19:41:49 +09:00
parent 2c042cee75
commit eb790760a2

View file

@ -973,7 +973,6 @@ impl<T> IoResultExt<T> for io::Result<T> {
mod dirty_cell {
use std::cell::{Cell, RefCell};
use std::ops::Deref;
/// Cell that lazily updates the value after `mark_dirty()`.
#[derive(Clone, Debug)]
@ -994,9 +993,7 @@ mod dirty_cell {
// SAFETY: get_mut/mark_dirty(&mut self) should invalidate any previously-clean
// references leaked by this method. Clean value never changes until then.
self.ensure_clean(f);
let borrow = self.value.borrow();
let temp_ref = borrow.deref();
unsafe { std::mem::transmute(temp_ref) }
unsafe { &*self.value.as_ptr() }
}
pub fn ensure_clean(&self, f: impl FnOnce(&mut T)) {