Add rust::Vec accessors
Adds operator[], at(), front(), and back() to rust::Vec.
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index d70d5a0..76fe8b7 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -208,6 +208,8 @@
void c_take_rust_vec(rust::Vec<uint8_t> v) { c_take_ref_rust_vec(v); }
+void c_take_rust_vec_index(rust::Vec<uint8_t> v) { c_take_ref_rust_vec_index(v); }
+
void c_take_rust_vec_shared(rust::Vec<Shared> v) {
uint32_t sum = 0;
for (auto i : v) {
@@ -230,6 +232,17 @@
}
}
+void c_take_rust_vec_shared_index(rust::Vec<Shared> v) {
+ if (v[0].z == 1010 &&
+ v.at(0).z == 1010 &&
+ v.front().z == 1010 &&
+ v[1].z == 1011 &&
+ v.at(1).z == 1011 &&
+ v.back().z == 1011) {
+ cxx_test_suite_set_correct();
+ }
+}
+
void c_take_ref_rust_vec(const rust::Vec<uint8_t> &v) {
uint8_t sum = std::accumulate(v.begin(), v.end(), 0);
if (sum == 200) {
@@ -237,6 +250,19 @@
}
}
+void c_take_ref_rust_vec_index(const rust::Vec<uint8_t> &v) {
+ if (v[0] == 86 &&
+ v.at(0) == 86 &&
+ v.front() == 86 &&
+ v[1] == 75 &&
+ v.at(1) == 75 &&
+ v[3] == 9 &&
+ v.at(3) == 9 &&
+ v.back() == 9) {
+ cxx_test_suite_set_correct();
+ }
+}
+
void c_take_ref_rust_vec_copy(const rust::Vec<uint8_t> &v) {
// The std::copy() will make sure rust::Vec<>::const_iterator satisfies the
// requirements for std::iterator_traits.