Skip to content
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

Swift Option<String> and Option<&str> #264

Merged
merged 1 commit into from
Mar 26, 2024
Merged

Swift Option<String> and Option<&str> #264

merged 1 commit into from
Mar 26, 2024

Conversation

chinedufn
Copy link
Owner

@chinedufn chinedufn commented Mar 26, 2024

Swift Option and Option<&str>

This commit adds support for passing Option<String> to and from
extern "Swift" functions, as well as for passing Option<&str> to
extern "Swift" functions.

For example, the following is now possible:

#[swift_bridge::bridge]
mod ffi {
    extern "Swift" {
        fn opt_string_function(arg: Option<String>) -> Option<String>;

        fn opt_str_function(arg: Option<&str>);
    }
}

Note that you can not yet return -> Option<&str> from Swift.

This is an uncommon use case, so we're waiting until someone actually
needs it.

@chinedufn chinedufn force-pushed the option-string branch 2 times, most recently from 021f042 to 9311e42 Compare March 26, 2024 00:23
This commit adds support for passing `Option<String>` to and from
`extern "Swift"` functions, as well as for passing `Option<&str>` to
extern "Swift" functions.

For example, the following is now possible:

```rust
#[swift_bridge::bridge]
mod ffi {
    extern "Swift" {
        fn opt_string_function(arg: Option<String>) -> Option<String>;

        fn opt_str_function(arg: Option<&str>);
    }
}
```

Note that you can not yet return `-> Option<&str>` from Swift.

This is an uncommon use case, so we're waiting until someone actually
needs it.
@chinedufn chinedufn merged commit 58f4a40 into master Mar 26, 2024
5 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant