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

Allow type aliases to be marked as Trivial. #325

Merged
merged 4 commits into from
Oct 4, 2020

Conversation

adetaylor
Copy link
Collaborator

@adetaylor adetaylor commented Sep 25, 2020

Fixes #313.

This is a breaking change as it requires all implementers of ExternType to add another associated type. Defaults for associated types are an unstable feature, the compiler tells me. Perhaps we should avoid this by using a new trait, ExternTypeKind, instead.

This change allows aliases:
  type Foo = bindgen::Bar;
and C++ opaque types:
  type Foo;
to declare that they're 'trivial' in the sense that:

* They have trivial move constructors
* They have no destructors

and therefore may be passed and owned by value in Rust.

A subsequent commit will add C++ static assertions.

This commit is a BREAKING CHANGE as it requires existing
ExternTypes to gain a new associated type
@adetaylor adetaylor marked this pull request as ready for review September 30, 2020 23:56
@adetaylor
Copy link
Collaborator Author

I've just read #308 and it looks like I should rebase on top of that, if you think it will land soon, as there's a lot of commonality. I also need to add some tests like that PR has done.

Copy link
Owner

@dtolnay dtolnay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thank you, this is terrific.

I am going to follow up with some minor fixups (which I'll link here) but this is nicely done.

@dtolnay
Copy link
Owner

dtolnay commented Oct 4, 2020

#333, #334, #335

@dtolnay
Copy link
Owner

dtolnay commented Oct 9, 2020

Published in 0.5.0 together with the 2 other breaking changes I had lined up (#341, #346).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

ExternTypes may be safely passed and returned by value
2 participants