Change string cast operators to explicit
diff --git a/demo-cxx/demo.cc b/demo-cxx/demo.cc
index b975e88..04287b8 100644
--- a/demo-cxx/demo.cc
+++ b/demo-cxx/demo.cc
@@ -10,7 +10,7 @@
ThingC::~ThingC() { std::cout << "done with ThingC" << std::endl; }
std::unique_ptr<ThingC> make_demo(rust::Str appname) {
- return std::unique_ptr<ThingC>(new ThingC(appname));
+ return std::unique_ptr<ThingC>(new ThingC(std::string(appname)));
}
const std::string &get_name(const ThingC &thing) { return thing.appname; }
diff --git a/include/cxxbridge.h b/include/cxxbridge.h
index c8f85a9..b5a6451 100644
--- a/include/cxxbridge.h
+++ b/include/cxxbridge.h
@@ -17,7 +17,7 @@
String &operator=(const String &other) noexcept;
String &operator=(String &&other) noexcept;
~String() noexcept;
- operator std::string() const;
+ explicit operator std::string() const;
// Note: no null terminator.
const char *data() const noexcept;
@@ -37,7 +37,7 @@
Str(std::string &&s) = delete;
Str(const Str &other) noexcept;
Str &operator=(Str other) noexcept;
- operator std::string() const;
+ explicit operator std::string() const;
// Note: no null terminator.
const char *data() const noexcept;