You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
lexopt tries not to convert strings unless absolutely necessary, but bin_name() deviates from that. The source code doesn't explain why. If bin_name() returned OsString, that'd be more consistent with other methods.
The text was updated successfully, but these errors were encountered:
I wrote up some considerations here but they fell through the gaps the first time I scrapped the method.
The main use case I envisioned for it was to show in help messages and error messages. Try running /bin/cat --help and /bin/cat doesnotexist: if you have GNU cat then you'll see
It's easy to format a &str but hard to format an &OsStr. With the current API you can do println!("Usage: {} blabla", parser.bin_name().unwrap_or("myprog"));, but if it returned an &OsStr you'd have to do more work.
Unlike a normal argument, which might be an actual file you have to open, I don't think there are any common cases where you'd absolutely have to process your own command name even if it's invalid unicode. (It's not even a good way of finding the actual executable.) But then a lossy decode might make more sense than ignoring it.
(I want to remove/overhaul the whole method, as discussed in #5 (comment))
lexopt
tries not to convert strings unless absolutely necessary, butbin_name()
deviates from that. The source code doesn't explain why. Ifbin_name()
returnedOsString
, that'd be more consistent with other methods.The text was updated successfully, but these errors were encountered: