dtolnay/cxx

Extern "Rust" types that are nonlocal

Offen

#496 geöffnet am 22.11.2020

 (5 Kommentare) (0 Reaktionen) (0 zugewiesene Personen)Rust (253 Forks)batch import
help wanted

Repository-Metriken

Stars
 (4.472 Sterne)
PR-Merge-Metriken
 (Durchschn. Merge 8m) (3 gemergte PRs in 30 T)

Beschreibung

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?

Contributor Guide