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

Support Vec<OpaqueRustType> as a fn arg #20

Merged
merged 1 commit into from
Jan 26, 2022
Merged

Conversation

chinedufn
Copy link
Owner

@chinedufn chinedufn commented Jan 26, 2022

For example, the following is now possible:

#[swift_bridge::bridge]
mod ffi {
    extern "Rust" {
        type ARustTypeInsideVecT;

        fn rust_reflect_vec_opaque_rust_type(
            arg: Vec<ARustTypeInsideVecT>,
        ) -> Vec<ARustTypeInsideVecT>;
    }
}

We also fix the RustVec's deinit to only free the underlying
Vec<T> if the RustVec is owned. This prevents a double free
after passing an owned RustVec from Swift to Rust.

We also fix the `RustVec`'s `deinit` to only free the underlying
`Vec<T>` if the RustVec is owned. This prevents a double free
after passing an owned `RustVec` from Swift to Rust.
@chinedufn chinedufn merged commit b26dcf9 into master Jan 26, 2022
@chinedufn chinedufn deleted the vec-opaque-rust-arg branch January 26, 2022 10:15
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.

None yet

1 participant