-
Notifications
You must be signed in to change notification settings - Fork 12.7k
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
Comments
This is a duplicate of #49802; an RFC was proposed for this and it just has to be implemented. :) |
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
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.The text was updated successfully, but these errors were encountered: