swift-bridge icon indicating copy to clipboard operation
swift-bridge copied to clipboard

Support failable initializers

Open NiwakaDev opened this issue 1 year ago • 1 comments
trafficstars

Related to #235.

This PR supports failable initializers.

Something like:

// Rust side
#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        #[swift_bridge(Equatable)]
        type FailableInitType;

        #[swift_bridge(init)]
        fn new() -> Option<FailableInitType>;
    }
}
// Swift side
let failableInitType = FailableInitType()
if failableInitType == nil {
    ~
} else {
   ~
}

See: Swift Documentation - Failable Initializers

NiwakaDev avatar Jun 11 '24 16:06 NiwakaDev

My feedback was minor, so feel free to Squash and merge after you address it.

When you Squash and merge remember to paste in your PR body as the commit message.


Alternatively you can rebase into a single commit, force push that, and then merge that. But Squash and merge essentially does the same thing.

chinedufn avatar Jun 13 '24 10:06 chinedufn

Hello, hello. Still planning to land this?

chinedufn avatar Jul 02 '24 21:07 chinedufn

Sorry. I'll address your review this weekend if possible.

NiwakaDev avatar Jul 02 '24 22:07 NiwakaDev