blob: b408f25522afc053217806a33f443452fc2bdc22 [file] [log] [blame]
David Tolnayc5a52f92020-09-14 00:43:29 -04001use alloc::boxed::Box;
2use alloc::string::String;
David Tolnay3384c142020-09-14 00:26:47 -04003use core::slice;
David Tolnay3c90cd22020-04-30 07:28:21 -07004
David Tolnay8f16ae72020-10-08 18:21:13 -07005#[export_name = "cxxbridge05$exception"]
David Tolnay3c90cd22020-04-30 07:28:21 -07006unsafe extern "C" fn exception(ptr: *const u8, len: usize) -> *const u8 {
7 let slice = slice::from_raw_parts(ptr, len);
8 let boxed = String::from_utf8_lossy(slice).into_owned().into_boxed_str();
9 Box::leak(boxed).as_ptr()
10}