out/tests/ffi/lib.rs.cc:1011:22: warning: 'cxxbridge03$std$vector$tests$Shared$get_unchecked' has C-linkage specified, but returns user-defined type 'const tests::Shared &' which is incompatible with C [-Wreturn-type-c-linkage]
const tests::Shared &cxxbridge03$std$vector$tests$Shared$get_unchecked(const ::std::vector<tests::Shared> &s, size_t pos) noexcept {
^
out/tests/ffi/lib.rs.cc:1038:17: warning: 'cxxbridge03$std$vector$tests$C$get_unchecked' has C-linkage specified, but returns user-defined type 'const tests::C &' which is incompatible with C [-Wreturn-type-c-linkage]
const tests::C &cxxbridge03$std$vector$tests$C$get_unchecked(const ::std::vector<tests::C> &s, size_t pos) noexcept {
^
2 warnings generated.
This adds support for passing C-style enums between Rust and C++.
We use the Rust representation for enums suggested by dtolnay in #132.
Note that as this does not use real enums, Rust code cannot treat them
as normal enums, e.g., by converting them to integers. But common
uses such as pattern matching remain unchanged.
https://en.cppreference.com/w/cpp/iterator/iterator_traits
`std::iterator_traits` requires the following 5 types:
- `difference_type` - a signed integer type that can be used to identify distance between iterators
- `value_type` - the type of the values that can be obtained by dereferencing the iterator. This type is void for output iterators.
- `pointer` - defines a pointer to the type iterated over (value_type)
- `reference` - defines a reference to the type iterated over (value_type)
- `iterator_category` - the category of the iterator. Must be one of iterator category tags.
The current `const_iterator` for `rust::Vec<T>` only defined `value_type` and `reference` which caused an error when using `std::copy` on gcc 7.5.0 on Ubuntu but seemed to work fine on MacOS.
Checking this in check_type_ref allows it to apply anywhere that a
reference is written, such as return position which was not covered by
the previous logic.