//! Wasm-specific glue code //! //! This is a private module use alloc::format;
/// In theory, this function may be useful for other backends eventually, but /// currently it is only useful in WASM so it is in this module. #[no_mangle] unsafeextern"C"fn diplomat_init() { #[cfg(debug_assertions)]
std::panic::set_hook(Box::new(panic_handler)); #[cfg(feature = "log")]
log::set_logger(&ConsoleLogger)
.map(|()| log::set_max_level(log::LevelFilter::Debug))
.unwrap();
}
fn panic_handler(info: &std::panic::PanicHookInfo) { let msg = match info.payload().downcast_ref::<&'static str>() {
Some(&s) => s,
None => match info.payload().downcast_ref::<String>() {
Some(s) => s.as_str(),
None => "Box<Any>",
},
};
let msg = match info.location() {
Some(l) => format!( "wasm panicked at {}:{}:{}:\n{msg}",
l.file(),
l.line(),
l.column(),
),
None => format!("wasm panicked at <unknown location>:\n{msg}"),
};
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.