dtolnay/cxx

Extern "Rust" types that are nonlocal

Aperta

#496 aperta il 22 nov 2020

 (5 commenti) (0 reazioni) (0 assegnatari)Rust (253 fork)batch import
help wanted

Metriche repository

Star
 (4472 stelle)
Metriche merge PR
 (Merge medio 8m) (3 PR mergiate in 30 g)

Descrizione

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?

Guida contributor