fp-library 0.17.0

A functional programming library for Rust featuring your favourite higher-kinded types and type classes.
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
//! Internal utility functions shared across the crate.

use std::any::Any;

/// Converts a panic payload into a human-readable `String`.
///
/// Handles the common cases where the payload is a `&str` or `String`,
/// and falls back to `"Unknown panic"` for other types.
pub(crate) fn panic_payload_to_string(payload: Box<dyn Any + Send>) -> String {
	if let Some(s) = payload.downcast_ref::<&str>() {
		s.to_string()
	} else if let Some(s) = payload.downcast_ref::<String>() {
		s.clone()
	} else {
		"Unknown panic".to_string()
	}
}