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

Cython: Omit per-variant tags in unions generated for Rust enums #748

Merged
merged 1 commit into from
Mar 31, 2022

Conversation

petrochenkov
Copy link
Contributor

The common tag should already be enough, all other tags are identical to it.
In Cython case they only create noise because the declarations only introduce names and do not determine layouts.

The common `tag` should already be enough, al other tags are identical to it.
In Cython case they only create noise because the declarations only introduce names and do not determine layouts.
if config.language != Language::Cython {
out.write("struct");
out.open_brace();
}
out.write_vertical_source_list(&body.fields, ListType::Cap(";"));
let start_field =
usize::from(inline_tag_field && config.language == Language::Cython);
Copy link
Collaborator

Choose a reason for hiding this comment

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

A bit subtle, might be a bit clearer with:

let fields_to_write = if inline_tag_field && config.language == Language::Cython {
    &body.fields[1..]
} else {
    &body.fields
};

But sure, fine.

@emilio emilio merged commit ca7a942 into mozilla:master Mar 31, 2022
mhallin added a commit to mhallin/cbindgen that referenced this pull request May 25, 2024
v0.22.0

      * Support rename rule for union body members (mozilla#751).
      * constant: Add support for associated constant expressions (mozilla#752).
      * Fix regression in CamelCase rename rule (should be lowerCamelCase) (mozilla#750).
      * enumeration: simplify standard types in variants (mozilla#749).
      * Avoid generating and writing bindings when called recursively (mozilla#747).
      * Cython: Omit per-variant tags in unions generated for Rust enums (mozilla#748).
      * Update various dependencies.

# Conflicts:
#	tests/rust/enum.toml
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

2 participants