1
Fork 0

Harden the pre-tyctxt query system against accidental recomputation

This commit is contained in:
Oli Scherer 2022-12-12 10:48:02 +00:00
parent b22c152958
commit 58782a8842
7 changed files with 78 additions and 63 deletions

View file

@ -40,6 +40,11 @@ impl<T> Steal<T> {
ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
}
#[track_caller]
pub fn get_mut(&mut self) -> &mut T {
self.value.get_mut().as_mut().expect("attempt to read from stolen value")
}
#[track_caller]
pub fn steal(&self) -> T {
let value_ref = &mut *self.value.try_write().expect("stealing value which is locked");