Test passing CxxVector by reference from Rust to C
diff --git a/tests/ffi/lib.rs b/tests/ffi/lib.rs
index d6a94e4..750b30e 100644
--- a/tests/ffi/lib.rs
+++ b/tests/ffi/lib.rs
@@ -45,6 +45,7 @@
fn c_take_unique_ptr_vector_u8(v: UniquePtr<CxxVector<u8>>);
fn c_take_unique_ptr_vector_f64(v: UniquePtr<CxxVector<f64>>);
fn c_take_unique_ptr_vector_shared(v: UniquePtr<CxxVector<Shared>>);
+ fn c_take_ref_vector(v: &CxxVector<u8>);
fn c_take_vec_u8(v: &Vec<u8>);
fn c_take_vec_shared(v: &Vec<Shared>);
fn c_take_callback(callback: fn(String) -> usize);
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index 372641c..04f5168 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -166,6 +166,12 @@
}
}
+void c_take_ref_vector(const std::vector<uint8_t> &v) {
+ if (v.size() == 4) {
+ cxx_test_suite_set_correct();
+ }
+}
+
void c_take_vec_u8(const rust::Vec<uint8_t> &v) {
uint8_t sum = std::accumulate(v.begin(), v.end(), 0);
if (sum == 200) {
diff --git a/tests/ffi/tests.h b/tests/ffi/tests.h
index ed07ce6..2c7428d 100644
--- a/tests/ffi/tests.h
+++ b/tests/ffi/tests.h
@@ -47,6 +47,7 @@
void c_take_unique_ptr_vector_u8(std::unique_ptr<std::vector<uint8_t>> v);
void c_take_unique_ptr_vector_f64(std::unique_ptr<std::vector<double>> v);
void c_take_unique_ptr_vector_shared(std::unique_ptr<std::vector<Shared>> v);
+void c_take_ref_vector(const std::vector<uint8_t> &v);
void c_take_vec_u8(const rust::Vec<uint8_t> &v);
void c_take_vec_shared(const rust::Vec<Shared> &v);
void c_take_callback(rust::Fn<size_t(rust::String)> callback);