diff --git a/book/src/binding/vec.md b/book/src/binding/vec.md index befd6fbb..a02b93c7 100644 --- a/book/src/binding/vec.md +++ b/book/src/binding/vec.md @@ -45,9 +45,9 @@ public: void reserve(size_t new_cap); void push_back(const T &value); void push_back(T &&value); - void clear(); template void emplace_back(Args &&...args); + void clear(); class iterator; iterator begin() noexcept; diff --git a/gen/src/write.rs b/gen/src/write.rs index a6d4e461..64d83110 100644 --- a/gen/src/write.rs +++ b/gen/src/write.rs @@ -1590,13 +1590,10 @@ fn write_rust_vec_impl(out: &mut OutFile, key: NamedImplKey) { instance, ); writeln!(out, "}}"); + writeln!(out, "template <>"); begin_function_definition(out); - writeln!( - out, - "void Vec<{}>::clear() noexcept {{", - inner, - ); + writeln!(out, "void Vec<{}>::clear() {{", inner); writeln!( out, " return cxxbridge1$rust_vec${}$clear(this);", diff --git a/include/cxx.h b/include/cxx.h index f8ccb6f6..36839515 100644 --- a/include/cxx.h +++ b/include/cxx.h @@ -318,13 +318,13 @@ public: T &at(std::size_t n); T &front() noexcept; T &back() noexcept; - void clear() noexcept; void reserve(std::size_t new_cap); void push_back(const T &value); void push_back(T &&value); template void emplace_back(Args &&...args); + void clear(); using iterator = typename Slice::iterator; iterator begin() noexcept; diff --git a/src/cxx.cc b/src/cxx.cc index 03f9c5af..4bdbd583 100644 --- a/src/cxx.cc +++ b/src/cxx.cc @@ -567,10 +567,10 @@ static_assert(sizeof(std::string) <= kMaxExpectedWordsInString * sizeof(void *), const rust::Vec *ptr) noexcept; \ void cxxbridge1$rust_vec$##RUST_TYPE##$reserve_total( \ rust::Vec *ptr, std::size_t new_cap) noexcept; \ - void cxxbridge1$rust_vec$##RUST_TYPE##$clear( \ - rust::Vec *ptr) noexcept; \ void cxxbridge1$rust_vec$##RUST_TYPE##$set_len(rust::Vec *ptr, \ - std::size_t len) noexcept; + std::size_t len) noexcept; \ + void cxxbridge1$rust_vec$##RUST_TYPE##$clear( \ + rust::Vec *ptr) noexcept; #define RUST_VEC_OPS(RUST_TYPE, CXX_TYPE) \ template <> \ @@ -602,9 +602,9 @@ static_assert(sizeof(std::string) <= kMaxExpectedWordsInString * sizeof(void *), cxxbridge1$rust_vec$##RUST_TYPE##$set_len(this, len); \ } \ template <> \ - void Vec::clear() noexcept { \ + void Vec::clear() { \ cxxbridge1$rust_vec$##RUST_TYPE##$clear(this); \ - } + } #define SHARED_PTR_OPS(RUST_TYPE, CXX_TYPE) \ static_assert(sizeof(std::shared_ptr) == 2 * sizeof(void *), ""); \ diff --git a/src/rust_vec.rs b/src/rust_vec.rs index 0f57ae45..47d49a7b 100644 --- a/src/rust_vec.rs +++ b/src/rust_vec.rs @@ -70,7 +70,7 @@ impl RustVec { } pub fn clear(&mut self) { - self.as_mut_vec().clear() + self.as_mut_vec().clear(); } }