-
Notifications
You must be signed in to change notification settings - Fork 21
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
Drop from_str
?
#61
Comments
How often do you expect people to just want a string, especially in prototyping? Dropping A part of me likes the separation of concerns with different functions, unsure how much that and me creating something similar in clap biases me towards the existing behavior. let file = long("foo").argument::<PathBuf>().os() I assume this would correctly map an |
Speaking of In a nutshell, think of it as a Other nice aspects of the design:
Besides the docs, the initial PR has some details |
Not very often, I tend to jump straight to the type I want to work with, at least if it's
If you want a string - it's still available, you just need to ask for it: let string = long("foo").argument<String>("FOO"); Main motivation is to make things more uniform between
If you use Hmmm... Actually I can probably get it to do the right thing even without |
Cool will take a look. |
https://crates.io/crates/castaway/0.2.1 is an interesting crate for limited forms of specialization. Unsure if its any different than just checking |
Seems to use Anyway, thanks for asking all the right questions, will see how far I can push to get it both |
Personally, I feel like that shouldn't be an automatic reason to reject things. |
I'm totally okay with using unsafe where appropriate - like dealing with pointers or networking magic, made a few pull requests to rust |
Okay, let file = positional::<String>("NAME").map(PathBuf::from); Naive version would do the right thing: let file = positional::<PathBuf>("NAME");
https://github.com/pacak/bpaf/blob/adjacent/examples/cat.rs - this can probably go into batteries, not sure how useful it in general.
If user wants a custom error - just grab a Now to go though all the documentation one more time cleaning up any mentionings of |
Currently to make a primitive parser you would typically do something like this
this uses
FromStr
or even uglier to parse a
PathBuf
.map
allows to use anything, typically it'sFrom
Is it an improvement to change it into - less words, more uniform way of dealing
This uses
FromStr
and this for
PathBuf
respectively?.os()
bit at the end is somewhat important. Sadly rust typesystem is not expressive enough...This uses
From
You can fallback to keep using
map
in either way but will have to specify what typeargument
should return.More yoda-speak though...
Derive API deals with those details internally.
@epage, thoughts?
The text was updated successfully, but these errors were encountered: