-
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
Implement Error for RustStringRef #282
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for making this contribution.
One question about why you introduced the LocalizedError
implementation.
Just needs an integration test. Potential approachBridge a function that returns swift-bridge/crates/swift-integration-tests/src/result.rs Lines 3 to 81 in de05902
Then add a test case that calls that function somewhere inside here swift-bridge/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift Line 10 in de05902
On the test case document that (I'm paraphrasing) around the time of Then confirm that if you comment out the |
@jnbooth Do you still work on this? |
Implemented in #296 |
Support Rust returning `-> Result<_, String>`, e.g.: ```rust #[swift_bridge::bridge] mod ffi { extern "Rust" { fn do_fallible_work() -> Result<(), String>; } } ``` --- Incorporate the changes from #282 to implement swift's `Error` protocol for ruststring, & extend them with the tests requested in #295 (comment)
With the latest versions of Swift, using
Result<_, String>
causes two errors:'RustString' is not convertible to 'any Error'
Thrown expression type 'RustString' does not conform to 'Error
The solution to both errors is for
RustStringRef
to declare conformance to theError
protocol.See: Swift Documentation - Error