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

Pass the try_from_str functions a &str instead of a &String. #282

Merged
merged 2 commits into from Nov 22, 2019

Conversation

m-ou-se
Copy link
Contributor

@m-ou-se m-ou-se commented Nov 22, 2019

In most cases this doesn't matter, as &String is coerced to a &str, but
this fails for generic functions like CString::new.

The added test failed to compile before this change.

In most cases this doesn't matter, as &String is coerced to a &str, but
this fails for generic functions like CString::new.
@TeXitoi
Copy link
Owner

TeXitoi commented Nov 22, 2019

Thanks for your contribution!

Some questions:

  • Don't we have the same problem with from_str, from_ostr and try_from_os_str
  • Don't we need to do this fix at some other places to be safe

Please also add a line in the CHANGELOG.md

@m-ou-se
Copy link
Contributor Author

m-ou-se commented Nov 22, 2019

It was only a problem in the validation step, not in the conversion step. So the non-try_ variants are fine.

try_from_os_str is also fine, because Clap's validator_os gives an &OsStr to the function. Only Clap's validator is a bit weird, as it gives a String (by value).

@TeXitoi
Copy link
Owner

TeXitoi commented Nov 22, 2019

Thanks.

@TeXitoi TeXitoi merged commit 1b998f5 into TeXitoi:master Nov 22, 2019
@m-ou-se m-ou-se deleted the as_str branch November 22, 2019 14:22
@TeXitoi
Copy link
Owner

TeXitoi commented Nov 22, 2019

v0.3.5 published

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