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

feat: add headers option #2743

Merged
merged 1 commit into from Feb 7, 2024
Merged

feat: add headers option #2743

merged 1 commit into from Feb 7, 2024

Conversation

christianheussy
Copy link
Contributor

Problem: It's cumbersome to define multiple input headers using the existing header API. It's difficult for the user to configure the Builder with a list of input headers.

Solution: Add headers method that permits adding multiple headers via an iterable of Strings.

Testing: Added test_headers_call_in_builder. Ran cargo test in bindgen-tests/tests/expectations.

Issue: #2738

Copy link
Contributor

@emilio emilio left a comment

Choose a reason for hiding this comment

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

Just minor bits.

bindgen/options/mod.rs Outdated Show resolved Hide resolved
where I::Item: Into<String>{
self.options.input_headers
.extend(headers.into_iter().map(Into::into).map(Into::into));
self
Copy link
Contributor

Choose a reason for hiding this comment

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

May be a bit simpler to do:

for h in headers {
    self = self.header(h);
}
self

But I guess this is fine as well, your call.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

My main concern was that the additional moves could have some sort of performance impact? Likely that's not a concern. I've left it as is, but let me know if you disagree and I can change it.

Problem: It's cumbersome to define multiple input headers using the
existing `header` API. It's difficult for the user to configure the
`Builder` with a list of input headers.

Solution: Add `headers` method that permits adding multiple headers via
an iterable of Strings.

Testing: Added `test_headers_call_in_builder`. Ran `cargo test` in
`bindgen-tests/tests/expectations`.

Issue: rust-lang#2738
@emilio emilio merged commit 4dd4523 into rust-lang:main Feb 7, 2024
33 checks passed
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