dtolnay/cxx

Extern "Rust" types that are nonlocal

Open

#496 创建于 2020年11月22日

在 GitHub 查看
 (5 评论) (0 反应) (0 负责人)Rust (4,472 star) (253 fork)batch import
help wanted

描述

The following worked prior to 1.0:

type DataSourcePrivate = Rc<DataSource>;

#[cxx::bridge(namespace = "mcrtlib::ffi")]
mod types {
    pub struct DataSource {
        pub inner: Box<DataSourcePrivate>,
    }

    extern "Rust" {
        type DataSourcePrivate;

        // ...
    }
}

However, now I just get a

error[E0117]: only traits defined in the current crate can be implemented for arbitrary types
  --> library/src/ffi.rs:85:9
   |
85 |         type DataSourcePrivate;
   |         ^^^^^-----------------
   |         |    |
   |         |    `Rc` is not defined in the current crate
   |         impl doesn't use only types from inside the current crate
   |
   = note: define and implement a trait or new type instead

Is it possible to make this work again or should I wrap my Rc in a tuple struct?

贡献者指南