pub trait CheckForPanics: Sized {
type Output;
// Required method
fn check_for_panics_with(
self,
panic_on_unexpected_termination: bool,
) -> Self::Output;
// Provided methods
fn panic_if_task_has_finished(self) -> Self::Output { ... }
fn panic_if_task_has_panicked(self) -> Self::Output { ... }
}
Expand description
A trait that checks a task’s return value for panics.
Required Associated Types§
Required Methods§
Sourcefn check_for_panics_with(
self,
panic_on_unexpected_termination: bool,
) -> Self::Output
fn check_for_panics_with( self, panic_on_unexpected_termination: bool, ) -> Self::Output
Check if self
contains a panic payload, then panic. Also panics if
panic_on_unexpected_termination
is true, and self
is an unexpected termination.
Otherwise, return the non-panic part of self
.
§Panics
If self
contains a panic payload, or if we’re panicking on unexpected terminations.
Provided Methods§
Sourcefn panic_if_task_has_finished(self) -> Self::Output
fn panic_if_task_has_finished(self) -> Self::Output
Check if self
contains a panic payload or an unexpected termination, then panic.
Otherwise, return the non-panic part of self
.
§Panics
If self
contains a panic payload or an unexpected termination.
Sourcefn panic_if_task_has_panicked(self) -> Self::Output
fn panic_if_task_has_panicked(self) -> Self::Output
Check if self
contains a panic payload, then panic.
Otherwise, return the non-panic part of self
.
§Panics
If self
contains a panic payload.
Dyn Compatibility§
This trait is not dyn compatible.
In older versions of Rust, dyn compatibility was called "object safety", so this trait is not object safe.
Implementations on Foreign Types§
Source§impl<T> CheckForPanics for &mut Option<Arc<JoinHandle<T>>>where
T: Debug,
impl<T> CheckForPanics for &mut Option<Arc<JoinHandle<T>>>where
T: Debug,
Source§fn check_for_panics_with(
self,
panic_on_unexpected_termination: bool,
) -> Self::Output
fn check_for_panics_with( self, panic_on_unexpected_termination: bool, ) -> Self::Output
If this is the final Arc
, checks if the thread has finished, then panics if the thread
panicked. Otherwise, returns the thread’s return value.
If the thread has not finished, or this is not the final Arc
, returns None
.
type Output = Option<T>
Source§impl<T> CheckForPanics for Result<T>where
T: Debug,
impl<T> CheckForPanics for Result<T>where
T: Debug,
Source§fn check_for_panics_with(
self,
panic_on_unexpected_termination: bool,
) -> Self::Output
fn check_for_panics_with( self, panic_on_unexpected_termination: bool, ) -> Self::Output
§Panics
- if the thread panicked.
- if the thread is cancelled,
panic_on_unexpected_termination
is true, and Zebra is not shutting down.
Threads can’t be cancelled except by using a panic, so there are no thread errors here.
panic_on_unexpected_termination
is