Skip to main content

message_to_c_string

Function message_to_c_string 

Source
pub fn message_to_c_string(message: &str) -> CString
Expand description

Converts a panic message into a CString, replacing any interior NUL.

CString::new rejects interior NULs, and a panic message is arbitrary user text — dropping the diagnostic because it happened to contain a NUL would be the wrong trade.

§Example

let c = quack_rs::callback::message_to_c_string("a\0b");
assert_eq!(c.to_str().unwrap(), "a?b");