mirror of
https://github.com/rust-lang/rust.git
synced 2025-01-22 12:43:36 +00:00
arrr caught ya caller
awd
This commit is contained in:
parent
73422130ee
commit
f1e71a5b41
@ -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]
|
||||
|
Loading…
Reference in New Issue
Block a user