-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Make opts_present and opts_str in the getopts module take &[&str] instead of &[String] #14453
Conversation
Alright, I'll fix that. |
I'm not totally comfortable with exploding our interfaces everywhere with Requiring |
I agree with @cmr, using |
So actually I think using |
No, the T does not get moved, it's a slice (non-owning view) into an array On Tue, May 27, 2014 at 8:31 PM, Gulshan Singh notifications@github.comwrote:
|
It cannot work for arrays. You still need to allocate a new vector. String On Tue, May 27, 2014 at 8:47 PM, Gulshan Singh notifications@github.comwrote:
|
@cmr I see now. I edited and deleted my previous comments before you replied, but it looks you replied to the email. I'm working on the change right now. |
eugh github-via-email can be so annoying sometimes. sorry :( |
Updated. |
Needs a rebase |
r=me though |
@cmr, Before r+'ing, what do you think of my earlier comment? Should we accept |
…tead of &[String]
I would hate to do that, because it's so, so ugly. In this case it's to On Fri, May 30, 2014 at 9:33 AM, Alex Crichton notifications@github.com
|
I do not believe that the paramount goal of Rust is to avoid all allocations wherever possible. This is an example I think of a location where avoiding an allocation barely matters because you're parsing options from the command line, which likely happens only once in a program. This looks like it's starting to set the trend of "take |
Rebased. |
I agree with the hesitation but I'm certainly not against removing On Fri, May 30, 2014 at 11:07 AM, Gulshan Singh notifications@github.com
|
Implicit coercion of This particular case is one that doesn't matter too much for allocation reasons, because it's largely just done once, but I actually think that using @alexcrichton A long time ago I had a PR to do something similar for |
Dealing with processes was a serious ergonomics issue because there were often many static strings that were used as arguments. That was an excellent impetus for the Dealing with The rationale for this PR, as stated in the description, is to save an allocation. This is a library which is never used in an inner loop, so I don't understand why saving an allocation should be a goal of this library. As I stated before, the goal of rust is not to minimize allocations. If a library allocates, that does not mean that it is sub-par or needs improvement. |
For implicit coercion I was referring to <T: Str> everywhere. On Fri, May 30, 2014 at 11:38 AM, Kevin Ballard notifications@github.com
|
@alexcrichton Ok, I agree, this particular library does not need to worry about allocations. My feeling is that encouraging a trend of To that end, we should probably close this PR for now, but accept if it it's re-submitted after other libraries have established the convention. |
Ok, I'm going to close this for now, and we'll see how the conventions play out in the future. |
There's no reason opts_present and opts_str need heap allocated strings.