Closed jnbooth closed 1 month ago
Just needs an integration test.
Bridge a function that returns -> Result<(), String>
. Somewhere in here https://github.com/chinedufn/swift-bridge/blob/de059024732fa2f8135a9fe1232b727d96794af6/crates/swift-integration-tests/src/result.rs#L3-L81
Then add a test case that calls that function somewhere inside here https://github.com/chinedufn/swift-bridge/blob/de059024732fa2f8135a9fe1232b727d96794af6/SwiftRustIntegrationTestRunner/SwiftRustIntegrationTestRunnerTests/ResultTests.swift#L10
On the test case document that (I'm paraphrasing) around the time of Swift x.y
returning -> Result<(), String>
started giving errors like Thrown expression type 'RustString' does not conform to 'Error'
. And that we solved that by implementing Swift's Error
protocol for RustStringRef
. And that the test is confirming that the Error
protocol is indeed implemented.
Then confirm that if you comment out the extension RustStringRef: Error {}
line then tests fail.
@jnbooth Do you still work on this?
Implemented in https://github.com/chinedufn/swift-bridge/pull/296
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