dtolnay/cxx

Box clone() member function to call Clone on opaque Rust types

开放

#105 创建于 2020年4月11日

 (3 条评论) (0 个反应) (0 位负责人)Rust (253 个派生)batch import
help wanted

仓库指标

星标
 (4,472 个星标)
PR 合并指标
 (平均合并 8分钟) (30 天内合并 3 个 PR)

描述

We should provide a way to constrain that some opaque Rust type implements Clone and then expose the Clone impl to C++ via a clone() member function on rust::Box.

Something like:

mod ffi {
    extern "Rust" {
        type ClonableR: Clone;
    }

    extern "C++" {
        fn f(b: Box<ClonableR>); // C++ will be able to clone b
    }
}
  template <typename T>
  class Box {
+   Box clone() const noexcept;
  };

贡献者指南