cxx 0.3.9

Safe interop between Rust and C++
Documentation
1
2
3
4
5
6
7
8
use std::slice;
use std::str;

#[export_name = "cxxbridge03$str$valid"]
unsafe extern "C" fn str_valid(ptr: *const u8, len: usize) -> bool {
    let slice = slice::from_raw_parts(ptr, len);
    str::from_utf8(slice).is_ok()
}