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

Rename string::push_str to string::concat #20857

Closed
sandeep-datta opened this issue Jan 10, 2015 · 1 comment
Closed

Rename string::push_str to string::concat #20857

sandeep-datta opened this issue Jan 10, 2015 · 1 comment
Labels
A-collections Area: `std::collections`

Comments

@sandeep-datta
Copy link
Contributor

Please consider renaming string::push_str() to string::concat(). Push_X() in the context of a collection means X will be added to the container as a single entity. Hence push_str() is meaningless for strings since a string can only contain characters (char != [char]).

If it is too late to rename then consider adding a method called concat() anyway.

Also consider renaming Vec::push_all() to Vec::concat() so that the name is consistent with String::concat().

@kmcallister kmcallister added A-libs A-collections Area: `std::collections` labels Jan 11, 2015
@erickt
Copy link
Contributor

erickt commented Jan 17, 2015

@SDX2000: Thanks for this! This would be probably more appropriate as a comment on the current collections reform RFC, so I'm going to close this and redirect you to comment there. Generally speaking though, we already have a function concat, so we do have some desire to not use the same name for different things. Instead, a better solution might be if we end up growing an AddAssign trait that we could instead write:

let mut v = String::new();
v += 'a';
v += "foo";

let mut v = Vec::new();
v += 1u8;
v += [2u8, 3, 4];

And not worry about the method. There is a chance we might be able to get this in for rust 1.0 if someone does the work :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
A-collections Area: `std::collections`
Projects
None yet
Development

No branches or pull requests

3 participants