Switch demo code to using std::make_unique

This commit is contained in:
David Tolnay 2020-05-11 20:35:14 -07:00
parent 9808ef177c
commit c13ad23d9c
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
4 changed files with 4 additions and 2 deletions

View File

@ -1,6 +1,7 @@
cxx_library(
name = "demo-cxx",
srcs = ["demo.cc"],
compiler_flags = ["-std=c++14"],
visibility = ["PUBLIC"],
deps = [
":include",

View File

@ -1,6 +1,7 @@
cc_library(
name = "demo-cxx",
srcs = ["demo.cc"],
copts = ["-std=c++14"],
visibility = ["//visibility:public"],
deps = [
":include",

View File

@ -10,7 +10,7 @@ ThingC::ThingC(std::string appname) : appname(std::move(appname)) {}
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(std::string(appname)));
return std::make_unique<ThingC>(std::string(appname));
}
const std::string &get_name(const ThingC &thing) { return thing.appname; }

View File

@ -1,7 +1,7 @@
fn main() {
cxx_build::bridge("src/main.rs")
.file("../demo-cxx/demo.cc")
.flag_if_supported("-std=c++11")
.flag_if_supported("-std=c++14")
.compile("cxxbridge-demo");
println!("cargo:rerun-if-changed=src/main.rs");