arrr caught ya caller

awd
This commit is contained in:
Ellen 2021-09-25 00:34:02 +01:00
parent 73422130ee
commit f1e71a5b41

View file

@ -33,10 +33,11 @@ impl<T> Steal<T> {
#[track_caller]
pub fn borrow(&self) -> MappedReadGuard<'_, T> {
ReadGuard::map(self.value.borrow(), |opt| match *opt {
None => panic!("attempted to read from stolen value"),
Some(ref v) => v,
})
let borrow = self.value.borrow();
if let None = &*borrow {
panic!("attempted to read from stolen value: {}", std::any::type_name::<T>());
}
ReadGuard::map(borrow, |opt| opt.as_ref().unwrap())
}
#[track_caller]