-
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 #[swift_bridge(Sendable)]
to implement Rust Send+Sync
for Swift Sendable
types
#269
Comments
Implementation GuideCheck out the contributing guide https://chinedufn.github.io/swift-bridge/contributing/adding-support-for-a-signature/index.html Here's a pull-request where we implemented support for Swift's It should serve as a guide for implementing
swift-bridge/crates/swift-bridge-ir/src/codegen/generate_rust_tokens.rs Lines 236 to 248 in dd5bef5
let impl_send_sync = if ty.attributes.sendable {
quote! {
unsafe impl Send for #ty_name {}
unsafe impl Sync for #ty_name {}
}
} else {
quote!{}
}; The
Example of an integration test: swift-bridge/crates/swift-integration-tests/src/swift_function_uses_opaque_rust_type.rs Lines 22 to 36 in 930866e
Lines 22 to 24 in 930866e
Here's where swift-bridge/crates/swift-bridge-build/src/generate_core.rs Lines 21 to 32 in 7e140ca
|
Rust Send+Sync
on Swift Sendable
types#[swift_bridge(Sendable)]
to implement Rust Send+Sync
for Swift Sendable
types
Right now when generating the Rust representation of a Swift type we create a non-Send and non-Sync type.
If the user knows that
SomeSwiftType
isSendable
then they should be able toSend + Sync
on the Rust side.Then it would generate Swift code like:
The text was updated successfully, but these errors were encountered: