Struct PoisonError
pub struct PoisonError<T> { pub(in ::sync::poison) data: T }
A type of error which can be returned whenever a lock is acquired.
Both Mutexes and RwLocks are poisoned whenever a thread fails while the lock
is held. The precise semantics for when a lock is poisoned is documented on
each lock. For a lock in the poisoned state, unless the state is cleared manually,
all future acquisitions will return this error.
Examples
use ;
use thread;
let mutex = new;
// poison the mutex
let c_mutex = clone;
let _ = spawn.join;
match mutex.lock ;
Fields
data: T
Implementations
impl<T> PoisonError<T>
fn new(data: T) -> PoisonError<T>Creates a
PoisonError.This is generally created by methods like
Mutex::lockorRwLock::read.This method may panic if std was built with
panic="abort".fn into_inner(self) -> TConsumes this error indicating that a lock is poisoned, returning the associated data.
Examples
use HashSet; use ; use thread; let mutex = new; // poison the mutex let c_mutex = clone; let _ = spawn.join; let p_err = mutex.lock.unwrap_err; let data = p_err.into_inner; println!;fn get_ref(&self) -> &TReaches into this error indicating that a lock is poisoned, returning a reference to the associated data.
fn get_mut(&mut self) -> &mut TReaches into this error indicating that a lock is poisoned, returning a mutable reference to the associated data.
Trait Implementations
impl<T> Debug for PoisonError<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T> Display for PoisonError<T>
fn fmt(&self, f: &mut Formatter<'_>) -> Result
impl<T> Error for PoisonError<T>
Auto Trait Implementations
impl<T> Freeze for PoisonError<T>
where
T: Freeze,
impl<T> RefUnwindSafe for PoisonError<T>
where
T: RefUnwindSafe,
impl<T> Send for PoisonError<T>
where
T: Send,
impl<T> Sync for PoisonError<T>
where
T: Sync,
impl<T> Unpin for PoisonError<T>
where
T: Unpin,
impl<T> UnsafeUnpin for PoisonError<T>
where
T: UnsafeUnpin,
impl<T> UnwindSafe for PoisonError<T>
where
T: UnwindSafe,
Blanket Implementations
impl<T> Any for PoisonError<T>
where
T: 'static + ?Sized,
fn type_id(&self) -> TypeId
impl<T> Borrow<T> for PoisonError<T>
where
T: ?Sized,
fn borrow(&self) -> &T
impl<T> BorrowMut<T> for PoisonError<T>
where
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
impl<T> From<T> for PoisonError<T>
fn from(t: T) -> TReturns the argument unchanged.
impl<T> SizeHint for PoisonError<T>
where
T: ?Sized,
fn lower_bound(&self) -> usizefn upper_bound(&self) -> Option<usize>
impl<T> SizedTypeProperties for PoisonError<T>
impl<T> ToString for PoisonError<T>
where
T: Display + ?Sized,
fn to_string(&self) -> String
impl<T, U> Into<U> for PoisonError<T>
where
U: From<T>,
fn into(self) -> UCalls
U::from(self).That is, this conversion is whatever the implementation of
[From]<T> for Uchooses to do.
impl<T, U> TryFrom<U> for PoisonError<T>
where
U: Into<T>,
type Error = Infallible;fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
impl<T, U> TryInto<U> for PoisonError<T>
where
U: TryFrom<T>,
type Error = <U as TryFrom<T>>::Error;fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>