chinedufn / swift-bridge

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

Clippy finds clippy::unnecessary-cast #245

Open bes opened 1 year ago

bes commented 1 year ago

Clippy complains:

error: casting raw pointers to the same type and constness is unnecessary (`*mut my_mod::FfiThing` -> `*mut my_mod::FfiThing`)

For this declaration:

#[swift_bridge::bridge]
mod ffi {

    // ...

    extern "Rust" {
        type FfiThing;

        #[swift_bridge(swift_name = "a")]
        fn a(&self) -> Option<FfiX>;

        #[swift_bridge(swift_name = "b")]
        fn b(&self) -> Option<FfiY>;
    }

    // ...
}

pub struct FfiThing {
    a: Option<FfiTypeA>,
    b: Option<FfiTypeB>,
}

impl FfiViewport {
    fn a(&self) -> Option<FfiTypeA> {
        self.a.clone()
    }
    fn b(&self) -> Option<FfiTypeB> {
        self.b.clone()
    }
}