| David Tolnay | c5a52f9 | 2020-09-14 00:43:29 -0400 | [diff] [blame] | 1 | use alloc::boxed::Box; |
| 2 | use alloc::string::String; |
| David Tolnay | 3384c14 | 2020-09-14 00:26:47 -0400 | [diff] [blame] | 3 | use core::slice; |
| David Tolnay | 3c90cd2 | 2020-04-30 07:28:21 -0700 | [diff] [blame] | 4 | |
| David Tolnay | 8f16ae7 | 2020-10-08 18:21:13 -0700 | [diff] [blame] | 5 | #[export_name = "cxxbridge05$exception"] |
| David Tolnay | 3c90cd2 | 2020-04-30 07:28:21 -0700 | [diff] [blame] | 6 | unsafe 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 | } |