I wrote a test program to check that the data will be read correctly on the Rust.
C++ code:
std::vector<float> vec;
vec.push_back(10);
vec.push_back(20);
std::cout << "len is " << get_len(&vec);
Rust code:
#[no_mangle]
pub extern "C" fn get_len(vec: *const Vec<f32>) -> i32 {
let vec= unsafe { &*vec};
vec.len() as i32
}
My output looks like this and is always different:
len is 603268424