`CxxVector` explicit shim impl fails: `patterns aren't allowed in foreign function declarations`
Author: DexterHill0Created May 16, 2026Updated Jun 22, 2026
#[cxx::bridge]
mod ffi1 {
unsafe extern "C++" {
type A;
}
impl CxxVector<A> {}
}This code will error with the following:
patterns aren't allowed in foreign function declarationsThis is because the __vector_size and __vector_capacity extern functions generate with _ as an argument rather than a single-letter variable. For whatever reason, rust is considering this a pattern match and erroring. The solution, as per the other vector methods, is to just make the argument a single letter or something like _v.
Source: dtolnay/cxx