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 Rust CoreAPI FFI to implement Default #5422

Merged
merged 1 commit into from
May 15, 2024
Merged

Conversation

rbran
Copy link
Contributor

@rbran rbran commented May 15, 2024

This allow writing simpler and cleaner code when initializing FFI types, avoiding the need of core::mem::zeroed().

It's specially useful to partially initialize structs:

BNHighlightColor {
  style: BNHighlightColorStyle::StandardHighlightColor,
  color: BNHighlightStandardColor::NoHighlightColor,
  alpha,
  ..Default::default()
}

@ElykDeer ElykDeer self-assigned this May 15, 2024
@ElykDeer
Copy link
Member

Please add an example of this somewhere, if it makes sense in any of our existing examples/docs.

@ElykDeer ElykDeer merged commit 50ce73a into Vector35:dev May 15, 2024
2 checks passed
@rbran
Copy link
Contributor Author

rbran commented May 15, 2024

It's not part of the public API, because right now the Core API FFI is not exposed. It's mostly to avoid unnecessary unsafe blocks on the API implementation.

@rbran rbran deleted the ffi-default branch May 15, 2024 18:21
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.

2 participants