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

Consider adding starts_with method for OsStr #49816

Closed
Kixunil opened this issue Apr 9, 2018 · 2 comments
Closed

Consider adding starts_with method for OsStr #49816

Kixunil opened this issue Apr 9, 2018 · 2 comments

Comments

@Kixunil
Copy link
Contributor

Kixunil commented Apr 9, 2018

When parsing arguments, one often wants to know whether the argument starts with "--" or "-". At the same time, args_os() is more robust approach because it allows specifying all paths OS allows.

However, since there's no starts_with method, this is impossible on Windows and requires OsStrExt trait with converting to byte slice on Unix. An imperfect workaround would be attempting to convert to &str and assume false if conversion fails (hoping argument names are sane - not containing non-ASCII chars).

Similarly, ends_with could be added.

I hope this doesn't need RFC, since it should be a very small and easy change.

Another thing that comes to my mind: arguments like --foo=bar can't be parsed - this requires slicing too.

@clarfonthey
Copy link
Contributor

This is a duplicate of #49802; an RFC was proposed for this and it just has to be implemented. :)

@Kixunil
Copy link
Contributor Author

Kixunil commented Apr 9, 2018

Weird that I didn't find it using Google. Thanks!

I'm closing in favor of that one.

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

No branches or pull requests

2 participants