Skip to content

Commit

Permalink
repo: simplify unsafe cast of view reference
Browse files Browse the repository at this point in the history
  • Loading branch information
yuja committed Nov 11, 2022
1 parent 2c042ce commit eb79076
Showing 1 changed file with 1 addition and 4 deletions.
5 changes: 1 addition & 4 deletions lib/src/repo.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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)]
Expand All @@ -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)) {
Expand Down

0 comments on commit eb79076

Please sign in to comment.