-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
only require Show for elements joined with connect #13911
Comments
Would it be a better idea to define connect() on iterators of strings instead? It would then just be:
but I think that explicit step is useful. It doesn't feel right for the formatting step to happen implicitly if there's no way to pass in a custom formatter. |
Theoretically we can have low-alloc The most general form would be something like fn connect_into<W: Writer, S: Show, It: Iterator<S>>(w: &mut W, it: It, connector: &str) {
for (i, x) in it.enumerate() {
if i == 0 {
write!(w, "{}", x);
} else {
write!(w, "{}{}", connector, x)
}
}
}
connect_into(&mut std::io::stdout(), range(0, 3), ", "); // prints: 0, 1, 2 (I guess you could even have the connector being generic too.) |
+1 for having connect for a Show or something simple like that |
Yes. It should definitely be defined for |
I'm pulling a massive triage effort to get us ready for 1.0. This method is now stable, and so would need to go through an RFC to change. This issue has been moved to the RFCs repo: rust-lang/rfcs#720 |
Add setting for limiting number of completions For rust-lang#13911.
… comments (rust-lang#13911) Fixes rust-lang#13692. If the `vec!` macro call contains comments, we should not provide suggestions and let users handle it however they see fit. changelog: Only emit `useless_vec` suggestion if the macro does not contain code comments
…mments (rust-lang#13940) Fixes rust-lang/rust-clippy#8528. Similar to rust-lang#13911, if there are code comments, we don't want to remove them automatically. changelog: Don't emit machine applicable `map_flatten` lint if there are code comments r? @xFrednet
In most high level languages it's easy to turn a list/array of things into a comma separated string. In Rust there is the
connect
method, but it requires the elements to implement the traitstd::str::Str
. I would like this method to requirestd::fmt::Show
instead. Alternatively ajoin
method with according semantics that requiresstd::fmt::Show
would suffice.Currently you have to write:
This is pretty horrible. This would be much nicer:
The text was updated successfully, but these errors were encountered: