Add Box construction tests

This commit is contained in:
David Tolnay 2020-12-12 16:21:16 -08:00
parent 0f1ac8b3fd
commit a141674f56
No known key found for this signature in database
GPG Key ID: F9BA143B95FF6D82
2 changed files with 11 additions and 0 deletions

View File

@ -276,6 +276,8 @@ pub mod ffi {
struct Dag4 {
dag0: Dag0,
}
impl Box<Shared> {}
}
mod other {

View File

@ -50,6 +50,15 @@ Shared c_return_shared() { return Shared{2020}; }
::A::B::ABShared c_return_nested_ns_shared() { return ::A::B::ABShared{2020}; }
rust::Box<R> c_return_box() {
Shared shared{0};
rust::Box<Shared> box{shared}; // explicit constructor from const T&
rust::Box<Shared> other{std::move(shared)}; // explicit constructor from T&&
box = other; // copy assignment
box = std::move(other); // move assignment
rust::Box<Shared> box2(box); // copy constructor
rust::Box<Shared> other2(std::move(other)); // move constructor
rust::Box<Shared>::in_place(shared.z); // placement static factory
rust::Box<Shared>::in_place<size_t>(0);
return rust::Box<R>::from_raw(cxx_test_suite_get_box());
}