Decouple Error from Str::Repr
It was misleading to use Str (which ordinarily represents borrowed
strings) also for owned error messages.
diff --git a/src/cxx.cc b/src/cxx.cc
index 43bf245..077f8ce 100644
--- a/src/cxx.cc
+++ b/src/cxx.cc
@@ -172,22 +172,21 @@
}
} // extern "C"
-Error::Error(Str::Repr msg) noexcept : msg(msg) {}
-
Error::Error(const Error &other) {
- this->msg.ptr = cxxbridge05$error(other.msg.ptr, other.msg.len);
- this->msg.len = other.msg.len;
+ this->msg = cxxbridge05$error(other.msg, other.len);
+ this->len = other.len;
}
Error::Error(Error &&other) noexcept {
this->msg = other.msg;
- other.msg.ptr = nullptr;
- other.msg.len = 0;
+ this->len = other.len;
+ other.msg = nullptr;
+ other.len = 0;
}
-Error::~Error() noexcept { delete[] this->msg.ptr; }
+Error::~Error() noexcept { delete[] this->msg; }
-const char *Error::what() const noexcept { return this->msg.ptr; }
+const char *Error::what() const noexcept { return this->msg; }
} // namespace cxxbridge05
} // namespace rust