-
Notifications
You must be signed in to change notification settings - Fork 62
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support failable Initializers for Opaque Types #235
Comments
I hadn't heard of this feature. Yeah this sounds like something that we want to support. I'm thinking we should also add a
|
Any updates on this? Would love to use failable initializers instead of a static methods that return optionals |
Not yet.
I guess that I can implement this issue in three weeks if needed. |
@chinedufn |
Yeah that would be great. I think "Failable Initializers" are ones that return an Feel free to implement either or both. |
Related to #235. This PR supports failable initializers. Something like: ```rust // Rust side #[swift_bridge::bridge] mod ffi { extern "Rust" { #[swift_bridge(Equatable)] type FailableInitType; #[swift_bridge(init)] fn new() -> Option<FailableInitType>; } } ``` ```swift // Swift side let failableInitType = FailableInitType() if failableInitType == nil { ~ } else { ~ } ``` See: [Swift Documentation - Failable Initializers](https://docs.swift.org/swift-book/documentation/the-swift-programming-language/initialization/#Failable-Initializers)
Next, I'll implement throwing initializers. I'd like to use this feature. |
Can we release a version that includes this feature? I'd like to use it. |
Released in |
Thank you!! |
Something like:
Or
I'd like to use this feature, but I don't know whether or not other users would like to.
The text was updated successfully, but these errors were encountered: