9

Github Tracking Issue for `panic_any` · Issue #78500 · rust-lang/rust · GitHub

 3 years ago
source link: https://github.com/rust-lang/rust/issues/78500
Go to the source link to view the article. You can view the picture content, updated content and better typesetting reading experience. If the link is broken, please click the button below to view the snapshot at that time.

Member

m-ou-se commented on Oct 29, 2020

edited

Feature gate: #![feature(panic_any)]

This is a tracking issue for std::panic::panic_any, a function to allow panicking with any value.

Context

Right now, it is possible to panic (that is, std::panic!) on any value: panic!(123). This will be disallowed in Rust 2021, when panic!(..) will always take a format string just like println!(..). At that point, this function will be the only way to panic without a (format) string. (See #80162 and rust-lang/rfcs#3007.)

Public API

mod std::panic {

    /// Panic the current thread with the given message as the panic payload.
    ///
    /// The message can be of any (`Any + Send`) type, not just strings.
    ///
    /// The message is wrapped in a `Box<'static + Any + Send>`, which can be
    /// accessed later using [`PanicInfo::payload`].
    ///
    /// See the [`panic!`] macro for more information about panicking.
    pub fn panic_any<M: Any + Send>(msg: M) -> !;

}

Steps / History

  • Implementation: #74622
  • Final commenting period (FCP)
  • Stabilization PR

Unresolved Questions

  • None yet.

About Joyk


Aggregate valuable and interesting links.
Joyk means Joy of geeK