-
Notifications
You must be signed in to change notification settings - Fork 1.6k
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 connect to join #1102
Rename connect to join #1102
Conversation
👍 |
+1 |
Having a deprecated method in a newborn language is not pretty. | ||
|
||
If we do remove the `.connect()` method, the language becomes pretty again, but | ||
it breaks the stability gurantee at the same time. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
s/gurantee/guarantee/
I approve, though I don't have a strong opinion. I do want to point out that if stability is an issue, we can have two names for the same function, and deprecate the older one. As I understand it, the core team has decided that adding methods without changing/removing existing methods is considered backwards compatible, even though there's a small chance of a name clash when adding a method. Not allowing methods to be added would be just too restrictive, since the standard library would really not be able to evolve its existing types. |
👍 |
I'd go as far as getting rid of #![feature(test)]
extern crate test;
#[bench]
fn connect(b: &mut test::Bencher) {
b.iter(|| {
["foo", "bar", "baz", "qux"].connect(" ")
});
}
#[bench]
fn concat(b: &mut test::Bencher) {
b.iter(|| {
["foo", "bar", "baz", "qux"].concat()
});
} Gives:
|
👍 from me - this was something I had to look up too. |
If we had done this earlier, deprecating/removing concat might have been fine, but I don't know if its worth doing it now. I don't have a strong opinion either way. |
Full support if we can deprecate the old names before 1.0, otherwise I think it's a silly change. We can live with a difference like this. |
Why not deprecate even after 1.0 @bluss? |
I'm not entirely against it, it just seems we could live with the difference instead. The name is not exactly monumental mistake. The positive sides are that deprecation is easy and the warning message should mean that almost everyone uses the non-deprecated name, but it's still another extra entry in the docs. |
@bluss a core team member is planning on having docs for deprecated items hidden by default |
Since the trait is marked as unstable, will any code currently building with the beta actually break if the methods are removed? |
Yes, because the methods are callable in beta (playpen link) fn main() {
println!("{}", ["foo", "bar", "baz", "qux"].connect(" "));
} |
@gsingh93 While the trait is unstable, the stable methods are already exported to the prelude. That's the problem! |
753b28c
to
568ed6a
Compare
👍 I've searched the docs for join a few times and came away empty-handed. Turns out it's there, but under an unexpected name. Let's maintain the principle of least astonishment. |
👍 I also had a lot of trouble finding this. |
👍 was also looking for this under the name "join". |
The libs team has been working through the RFC backlog, and I wanted to restart discussion on this RFC. Unfortunately, since 1.0 has shipped, the calculus here is perhaps a bit different than during the original comment period. In particular, since the While I'm definitely sympathetic to the idea that matching existing precedent is good, I also feel that |
This seems like another great candidate for something like On Thu, Jun 11, 2015 at 10:33 AM, Aaron Turon notifications@github.com
|
I suggest |
The problem with |
This RFC is now entering its week-long final comment period. |
👍 This bit me three times until I could finally remember what Rust called this method (the second and third times, all I could remember was "it's called something stupid which I expect to mean something else" and not the name). This is a nasty newbie trap; I can't think of any good reason to not at least introduce |
👍 for join. I think it is worth the deprecation. |
👍 When first trying Rust, I spent a long time looking for this functionality under I can definitely understand the reluctance to deprecate, but I think |
I am somewhat confused as to why this method is defined on slices in the first place as opposed to iterators. If I want to project strings out of a collection of structs and then join them, I'd currently have to collect them into a I'd like to see a proposal for the addition of a EDIT: If the API moves to |
@sfackler When slices already are present, it's a great advantage to use that, because the implementations walk them twice, once to compute the exact space needed and once to do the concatenation. When the slice is already present this is much superior, and it might even be more performant even when including a collect, depending on the number and length of the strings. So that's the benefit of slices, that doesn't preclude a method on iterators. We absolutely should opt for consistency though — I'm in favour of .connect() on an iterator if that's the name that stays. |
@bluss I don't see why it has to be a slice if a clonable iterator is sufficient. |
I'm used to |
👍 If I were looking for this method, I would look for |
I'm in favour of |
@Veedrac I think the main downside currently is that rust-lang/rust#23501 is not implemented, so much of current iterator usage isn't currently cloneable? |
@Ryman That's not much of a problem, since it still leaves us in a strictly better situation whilst we're waiting. |
Why does the iterator need to be clonable? Being able to allocate the space up front does not seem to be sufficiently amazing to forbid |
👍 |
I'm fine with adding |
The libs team did not reach consensus on this issue during this past FCP. To help focus the discussion though we think that the question of what this method is defined on (slices or iterators) is orthogonal to what it's called, so a future RFC can tweak this design but that's not quite the focus of this RFC. Additionally it's probably not worth blocking this RFC on waiting for a system for renaming methods, so the only major objection to this is that it may not be worth the cost that it incurs (e.g. deprecating a method, straddling versions is harder, etc). The support here may be enough to outweigh this, however. As a result we're going to leave this RFC in the FCP for another week. |
👍 Got bitten by this yesterday! |
👍 |
1 similar comment
👍 |
👍 for |
👍 I agree with @lambda in regards to an eventual deprecation after a period of a stable alias. This bit me when I first tried rust as I was so used to it being called |
After this next week of FCP the libs team is now in consensus to merge this RFC, so I shall do so. Thanks again for the discussion everyone and for the RFC @barosl! |
\0/ |
Kawaii version
Related Rust issue: rust-lang/rust#24645