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

Explicitly requesting an instantiation #336

Merged
merged 5 commits into from
Oct 4, 2020
Merged

Explicitly requesting an instantiation #336

merged 5 commits into from
Oct 4, 2020

Conversation

dtolnay
Copy link
Owner

@dtolnay dtolnay commented Oct 4, 2020

As discussed in #312 and elsewhere. Supersedes #329. We use the following impl syntax to indicate that we'd like the expansion of the ffi mod to include a given instantiation of UniquePtr, even if otherwise not mentioned in any of the extern function signatures:

#[cxx::bridge]
mod ffi {
    extern "C" {
        type C;
    }

    impl UniquePtr<C> {}
}

The same also works if the UniquePtr were to be an extern type alias (type C = path::to::C;). In that case it's up to the user whether to place the UniquePtr impl in one ffi module or the other, subject to the Rust orphan rule.

Closes #236. Closes #312. Closes #329.

@dtolnay dtolnay merged commit 1cbd1b2 into master Oct 4, 2020
@dtolnay dtolnay deleted the impl branch October 4, 2020 07:35
Repository owner locked and limited conversation to collaborators Jan 27, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Trait impls needed for type aliases Legitimate uses for UniquePtrs even if not currently expanded
1 participant