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

Added Mul for ~str #7937

Closed
wants to merge 2 commits into from
Closed

Added Mul for ~str #7937

wants to merge 2 commits into from

Conversation

MaikKlein
Copy link
Contributor

You can now do:

~"a" * 10 // ~"aaaaaaaaaa"

@MaikKlein
Copy link
Contributor Author

making use of .repeat now

@huonw
Copy link
Member

huonw commented Jul 21, 2013

This should implement it on &'self str and @str as well, no need to force 2 allocations for "abc" * 100. (You could even squash the commits into one, since they're conceptually the same; but this isn't necessary.)

@bstrie
Copy link
Contributor

bstrie commented Jul 21, 2013

I'd like one of the main developers to comment on this before anyone approves it. Operator overloads can be a contentious subject.

@brson
Copy link
Contributor

brson commented Jul 21, 2013

I'm not in favor of doing this. For me multiplying strings crosses the too-clever line.

@brendanzab
Copy link
Member

.repeat isn't really all that verbose, and much more readable.

@bstrie
Copy link
Contributor

bstrie commented Jul 22, 2013

I'm going to close this, as brson disapproves and I think Rust's general policy is that operator overloads should only be provided for common operations (which imo string repeating is not). @MaikKlein, feel free to open an issue rather than a PR if you wish to discuss it further.

@bstrie bstrie closed this Jul 22, 2013
flip1995 pushed a commit to flip1995/rust that referenced this pull request Nov 23, 2021
…shearth

Remove rustfmt::skip attribute from register_plugins function

r? `@Manishearth` since you added this in rust-lang#540 😄

changelog: none
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

5 participants