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 both &[CString] and &[&CStr] for sequence args in unistd #1278

Merged
merged 1 commit into from
Aug 22, 2020

Conversation

youknowone
Copy link
Contributor

I am new to this project, so I wonder this kind of change is acceptable for the project or not.

I agree taking &[&CStr] is the ideal way for the functions. But unfortunately, when users generate CStrings from &str, they may get &[CString] rather than &[&CStr]
Unlike single CString to &CStr argument, there is no easy way to convert &[CString] to &[&CStr] without creating new vector.

By changing the type from &[&CStr] to &[AsRef<CStr>], the args now can take both &[CString] and &[&CStr] without changing that much from nix.

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

Yes, that sounds like a good change. Could you please add a CHANGELOG entry? We also require tests for all new functionality. These functions already have some tests in test/test_unistd.rs. But it might be more appropriate in this case to add some doc tests.

@youknowone
Copy link
Contributor Author

I fixed test_unistd.rs to check both types of input

@youknowone
Copy link
Contributor Author

@asomers would you review this PR again?

Copy link
Member

@asomers asomers left a comment

Choose a reason for hiding this comment

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

bors r+

@bors
Copy link
Contributor

bors bot commented Aug 22, 2020

Build succeeded:

@bors bors bot merged commit 8ab88ee into nix-rust:master Aug 22, 2020
@youknowone youknowone deleted the sequence branch August 25, 2020 02:11
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