diff options
Diffstat (limited to 'library/core/src/panic.rs')
| -rw-r--r-- | library/core/src/panic.rs | 7 |
1 files changed, 6 insertions, 1 deletions
diff --git a/library/core/src/panic.rs b/library/core/src/panic.rs index 8771f40f9b4..b5a0932221a 100644 --- a/library/core/src/panic.rs +++ b/library/core/src/panic.rs @@ -144,7 +144,7 @@ pub macro unreachable_2021 { /// use. #[unstable(feature = "std_internals", issue = "none")] #[doc(hidden)] -pub unsafe trait PanicPayload { +pub unsafe trait PanicPayload: crate::fmt::Display { /// Take full ownership of the contents. /// The return type is actually `Box<dyn Any + Send>`, but we cannot use `Box` in core. /// @@ -157,4 +157,9 @@ pub unsafe trait PanicPayload { /// Just borrow the contents. fn get(&mut self) -> &(dyn Any + Send); + + /// Try to borrow the contents as `&str`, if possible without doing any allocations. + fn as_str(&mut self) -> Option<&str> { + None + } } |
