You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
Tracking Issue for PanicHookInfo::payload_as_str() #125175
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
The documentation on payload_as_str is reproduced here:
Returns the payload associated with the panic, if it is a string.
This returns the payload if it is of type &'static str or String.
A invocation of the panic!() macro in Rust 2021 or later will always result in a panic payload where payload_as_str returns Some.
Only an invocation of panic_any (or, in Rust 2018 and earlier, panic!(x) where x is something other than a string) can result in a panic payload where payload_as_str returns None.
I'm unsure, would you say that it is written in such a way that we could allow changing it to also internally also cast e.g. Box<str> or Cow<'static, str>, or perhaps even dyn AsRef<str>? If not, then I think perhaps that should be changed before stabilization?
I'm unsure, would you say that it is written in such a way that we could allow changing it to also internally also cast e.g. Box<str> or Cow<'static, str>, or perhaps even dyn AsRef<str>?
Yes. It says it is guaranteed to return Some if it contains a &str or String, not that it is guaranteed to return None if it is neither.
Activity
m-ou-se commentedon Sep 23, 2024
PanicHookInfo(as a separate type fromPanicInfo) has been stablized. Time to stabilizePanicHookInfo::payload_as_str(). :)This replaces the 'try to cast to str otherwise try to cast to String' pattern that basically every user of
PanicHookInfois doing today.@rfcbot merge
rfcbot commentedon Sep 23, 2024
Team member @m-ou-se has proposed to merge this. The next step is review by the rest of the tagged team members:
No concerns currently listed.
Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up!
See this document for info about what commands tagged team members can give me.
rfcbot commentedon Sep 23, 2024
🔔 This is now entering its final comment period, as per the review above. 🔔
madsmtm commentedon Sep 28, 2024
The documentation on
payload_as_stris reproduced here:I'm unsure, would you say that it is written in such a way that we could allow changing it to also internally also cast e.g.
Box<str>orCow<'static, str>, or perhaps evendyn AsRef<str>? If not, then I think perhaps that should be changed before stabilization?rfcbot commentedon Oct 3, 2024
The final comment period, with a disposition to merge, as per the review above, is now complete.
As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed.
This will be merged soon.
m-ou-se commentedon Aug 5, 2025
Yes. It says it is guaranteed to return
Someif it contains a&strorString, not that it is guaranteed to returnNoneif it is neither.Rollup merge of rust-lang#144861 - Kivooeo:payload-as-str-stabilizati…
Rollup merge of rust-lang#144861 - Kivooeo:payload-as-str-stabilizati…
Unrolled build for #144861
Rollup merge of rust-lang#144861 - Kivooeo:payload-as-str-stabilizati…