dtolnay / cxx

Safe interop between Rust and C++
https://cxx.rs
Apache License 2.0
5.68k stars 320 forks source link

Unsupported element type of Vec<[u64; 3]> #1354

Open chris838 opened 3 weeks ago

chris838 commented 3 weeks ago

It seems like cxx rejects Vec<[u64; 3]> as a supported type, though Vec<T> and [T; N] are both supported individually.

Steps to reproduce:

// main.rs
include!("include/foo.h");
#[cxx::bridge]
pub mod ffi {

    unsafe extern "C++" {
        fn foo(x: Vec<[u64; 3]>);
    }
}
// foo.h
void foo(rust::Vec<std::array<uint64_t, 3>> x);

Produces the following error:

  error[cxxbridge]: unsupported element type of Vec
     ┌─ src/main.rs:17:19
     │
  17 │         fn foo(x: Vec<[u64; 3]>);
     │                   ^^^^^^^^^^^^^ unsupported element type of Vec

Referenced from this SA question: https://stackoverflow.com/questions/78616935/binding-rust-vect-n-to-c-using-cxx?noredirect=1#comment138602956_78616935