pub struct PanicMsg<M: Display = &'static str> { /* private fields */ }
Expand description
A message for runtime panics. When one of the methods is called on it, the given message is used as the output for the panic.
§Example
const EXAMPLE_PANIC: PanicMsg = PanicMsg::new("This is an example panic message.");
// ...
EXAMPLE_PANIC.panic();
// ...
EXAMPLE_PANIC.panic_if(left >= right);
// ...
EXAMPLE_PANIC.assert(left < right);
// ...
EXAMPLE_PANIC.assert_eq(left, right);
// ...
EXAMPLE_PANIC.assert_ne(left, right);
// ...
EXAMPLE_PANIC.expect(option);
// ...
EXAMPLE_PANIC.expect(result);
// ...
EXAMPLE_PANIC.debug_panic();
// ...
EXAMPLE_PANIC.debug_panic_if(left >= right);
// ...
EXAMPLE_PANIC.debug_assert(left < right);
// ...
EXAMPLE_PANIC.debug_assert_eq(left, right);
// ...
EXAMPLE_PANIC.debug_assert_ne(left, right);
Implementations§
Source§impl<M: Display> PanicMsg<M>
impl<M: Display> PanicMsg<M>
Sourcepub fn assert(&self, condition: bool)
pub fn assert(&self, condition: bool)
Asserts that a boolean expression is true
at runtime.
see assert.
Sourcepub fn debug_panic(&self)
pub fn debug_panic(&self)
Panic at runtime with debug_assertions
.
See panic.
Sourcepub fn debug_panic_if(&self, condition: bool)
pub fn debug_panic_if(&self, condition: bool)
Panic if the condition is true
at runtime with debug_assertions
.
See panic.
Sourcepub fn debug_assert(&self, condition: bool)
pub fn debug_assert(&self, condition: bool)
Asserts that a boolean expression is true
at runtime with debug_assertions
.
see assert.
Sourcepub fn debug_assert_eq<L, R>(&self, lhs: L, rhs: R)
pub fn debug_assert_eq<L, R>(&self, lhs: L, rhs: R)
Sourcepub fn debug_assert_ne<L, R>(&self, lhs: L, rhs: R)
pub fn debug_assert_ne<L, R>(&self, lhs: L, rhs: R)
pub fn expect<T: IntoOption>(&self, value: T) -> T::OptionT
Trait Implementations§
Source§impl<M: Display> BorrowMut<M> for PanicMsg<M>
impl<M: Display> BorrowMut<M> for PanicMsg<M>
Source§fn borrow_mut(&mut self) -> &mut M
fn borrow_mut(&mut self) -> &mut M
Mutably borrows from an owned value. Read more
Source§impl<M: Display + Ord> Ord for PanicMsg<M>
impl<M: Display + Ord> Ord for PanicMsg<M>
Source§impl<M: Display + PartialOrd> PartialOrd<M> for PanicMsg<M>
impl<M: Display + PartialOrd> PartialOrd<M> for PanicMsg<M>
Source§impl<M: Display + PartialOrd> PartialOrd for PanicMsg<M>
impl<M: Display + PartialOrd> PartialOrd for PanicMsg<M>
impl<M: Display + Copy> Copy for PanicMsg<M>
impl<M: Display + Eq> Eq for PanicMsg<M>
Auto Trait Implementations§
impl<M> Freeze for PanicMsg<M>where
M: Freeze,
impl<M> RefUnwindSafe for PanicMsg<M>where
M: RefUnwindSafe,
impl<M> Send for PanicMsg<M>where
M: Send,
impl<M> Sync for PanicMsg<M>where
M: Sync,
impl<M> Unpin for PanicMsg<M>where
M: Unpin,
impl<M> UnwindSafe for PanicMsg<M>where
M: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more