chinedufn / swift-bridge

swift-bridge facilitates Rust and Swift interop.
https://chinedufn.github.io/swift-bridge
Apache License 2.0
810 stars 58 forks source link

Apply input module visibility to output module #284

Closed jnbooth closed 1 month ago

jnbooth commented 2 months ago

Addresses #252.

Here's an example of using this.

// enums.rs

#[swift_bridge::bridge]
pub mod ffi {
    enum MyEnum {
        VariantA,
        VariantB,
        VariantC,
    }
}

// lib.rs
mod enums;
use enums::ffi::MyEnum;

#[swift_bridge::bridge]
mod ffi {
  #[swift_bridge(already_declared)]
  enum MyEnum {}

  extern "Rust" {
    fn getEnum() -> MyEnum;
  }
}
jnbooth commented 1 month ago

@chinedufn Done. Thank you for providing the example!

chinedufn commented 1 month ago

Ooo nice example.

Thanks for submitting and landing your first contribution!