Remove Str and Slice swaps
diff --git a/include/cxx.h b/include/cxx.h
index 6c9a3a0..bb24b10 100644
--- a/include/cxx.h
+++ b/include/cxx.h
@@ -106,8 +106,6 @@
std::size_t size() const noexcept;
std::size_t length() const noexcept;
- void swap(Str &) noexcept;
-
// Important in order for System V ABI to pass in registers.
Str(const Str &) noexcept = default;
~Str() noexcept = default;
@@ -127,8 +125,6 @@
bool operator>=(const Str &) const noexcept;
private:
- friend void swap(Str &lhs, Str &rhs) noexcept { lhs.swap(rhs); }
-
// Not necessarily ABI compatible with &str. Codegen will translate to
// cxx::rust_str::RustStr which matches this layout.
const char *ptr;
@@ -168,8 +164,6 @@
std::size_t length() const noexcept;
bool empty() const noexcept;
- void swap(Slice &) noexcept;
-
T &operator[](std::size_t n) const noexcept;
T &at(std::size_t n) const;
T &front() const noexcept;
@@ -184,8 +178,6 @@
iterator end() const noexcept;
private:
- friend void swap(Slice<T> &lhs, Slice<T> &rhs) noexcept { lhs.swap(rhs); }
-
// Not necessarily ABI compatible with &[T]. Codegen will translate to
// cxx::rust_slice::RustSlice which matches this layout.
void *ptr;
@@ -527,13 +519,6 @@
}
template <typename T>
-void Slice<T>::swap(Slice<T> &rhs) noexcept {
- using std::swap;
- swap(this->ptr, rhs.ptr);
- swap(this->len, rhs.len);
-}
-
-template <typename T>
bool Slice<T>::empty() const noexcept {
return this->len == 0;
}
diff --git a/src/cxx.cc b/src/cxx.cc
index 269027a..0498655 100644
--- a/src/cxx.cc
+++ b/src/cxx.cc
@@ -215,12 +215,6 @@
return std::string(this->data(), this->size());
}
-void Str::swap(Str &rhs) noexcept {
- using std::swap;
- swap(this->ptr, rhs.ptr);
- swap(this->len, rhs.len);
-}
-
Str::const_iterator Str::begin() const noexcept { return this->cbegin(); }
Str::const_iterator Str::end() const noexcept { return this->cend(); }
diff --git a/tests/ffi/tests.cc b/tests/ffi/tests.cc
index 7eaee48..548ad13 100644
--- a/tests/ffi/tests.cc
+++ b/tests/ffi/tests.cc
@@ -751,6 +751,8 @@
ASSERT(r->get() == 2020);
ASSERT(r->set(2021) == 2021);
ASSERT(r->get() == 2021);
+
+ using std::swap;
auto r2 = r_return_box();
swap(r, r2);
ASSERT(r->get() == 2020);