-
Notifications
You must be signed in to change notification settings - Fork 13.1k
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
std: Remove index notation on slice iterators #25006
Conversation
r? @gankro (rust_highfive has picked a reviewer for you, use r? to override) |
r? @aturon |
Note that I figured that the |
@alexcrichton But the main holdup with that RFC remains the I think there are also some other concerns about this |
@@ -964,7 +961,7 @@ pub fn as_string<'a>(x: &'a str) -> DerefString<'a> { | |||
DerefString { x: as_vec(x.as_bytes()) } | |||
} | |||
|
|||
#[unstable(feature = "collections", reason = "associated error type may change")] | |||
#[stable(feature = "rust1", since = "1.0.0")] |
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.
re: the unstable comment -- should we consider future-proofing this by returning a newtype around unit?
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.
Oh wow I totally missed that! I think that it may actually be appropriate in this case as String::from_str
can never fail. It would in theory be more appropriately represented as Result<String, Void>
, but adding Void
probably isn't super well motivated by this use case.
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.
Right, but this might be one reason to leave it opaque for the time being -- so that if we get Void
(which has come up from time to time, and is a tiny API) we could switch over to it.
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.
Hm ok, I've switched it over to an #[unstable]
ParseError
newtype in the module.
I don't recall where the |
@aturon hm yes those are good points, I would also be fine removing the |
5bdc2ab
to
c41497f
Compare
I've pushed a new commit which removes the |
2f3ea53
to
776b4d0
Compare
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes rust-lang#24791
776b4d0
to
b1976f1
Compare
Note: @alexcrichton and I discussed this further, and determined that the |
These implementations were intended to be unstable, but currently the stability attributes cannot handle a stable trait with an unstable `impl` block. This commit also audits the rest of the standard library for explicitly-`#[unstable]` impl blocks. No others were removed but some annotations were changed to `#[stable]` as they're defacto stable anyway. One particularly interesting `impl` marked `#[stable]` as part of this commit is the `Add<&[T]>` impl for `Vec<T>`, which uses `push_all` and implicitly clones all elements of the vector provided. Closes #24791 [breaking-change]
@aturon thanks for the info. Shouldn't we have an RFC-style discussion about it? |
@bluss The sense was that these operators are widely used enough and match the collections reform reasonably enough to be stabilized as-is. (The complaints I've heard about them -- operator "abuse" -- apply equally to the set operations which were approved in the earlier RFC.) We're still working out exactly what requires an RFC, but this simple ungating didn't seem to warrant it. That all said, if you have objections I would love to hear about your concerns, and we could certainly consider removing the implementations for now (though that would likely break code). |
I've had these objections for a long time, and I'm sure I've explained before.
|
cc @bstrie I think you wanted to know about Add for Vec. |
@bluss Sorry to make you repeat yourself! I think I must have missed the previous discussion on this topic. @alexcrichton Perhaps we should consider removing the impls for now, after all, and have them go through an explicit RFC process as @bluss is requesting? I feel like it's a borderline case (came in without an RFC), but it's certainly an optional enough feature that removing it shouldn't cause much pain. @gankro I'd also appreciate your thoughts here. |
I'm not trying to obstruct, just stating my thoughts faithfully. I am sure many are happy with the current status of the |
@bluss Oh, totally! For my part, it seemed like a pretty minor thing but still better to go through the RFC process if we have doubts. |
…25006 but #24748 is fixed, so we can remove that workaround.
I'd be fine removing the impl, but I also do not feel strongly one way or another. |
@bluss I'm not necessarily a fan of using My personal concern is efficiency. If we're going to favor the operation with syntax, then it has to be fast. I don't want this being a perf footgun that we have to tell people to avoid. |
Does decision on rust-lang/rfcs#839 need to happen before 1.0? |
@bstrie Please note that vector addition means something very different than vector concatenation. It could very well be argued that Languages like php, javascript, python and java which conflate addition and concatenation all have some gotchas related to it. Lua has a '_' operator for concatenation (which we unfortunately cannot copy), while PL/SQL uses '||' (which unfortunately is hardwired or, so we cannot overload it). I quite like the idea of a concatenation operator. Especially with string handling, which is quite a common task, it could simplify things a bit. However, I feel that the choice of '+' is a poor one, and a better choice will need more thought. |
@llogiq Overloading |
@bstrie yes agreed, though since bitwise and isn't used as often as arithmetic addition, it perhaps carries less connotations. As I said, finding a good solution needs more thought. If we don't want to overload an existing operator, possible candidates include ℅, ~~, ^^, ++, --, **, <>, ><, ~ (as infix) Candidates for overloading are &, |, .., << (C++ anyone) and a lot of others. |
These implementations were intended to be unstable, but currently the stability
attributes cannot handle a stable trait with an unstable
impl
block. Thiscommit also audits the rest of the standard library for explicitly-
#[unstable]
impl blocks. No others were removed but some annotations were changed to
#[stable]
as they're defacto stable anyway.One particularly interesting
impl
marked#[stable]
as part of this commitis the
Add<&[T]>
impl forVec<T>
, which usespush_all
and implicitlyclones all elements of the vector provided.
Closes #24791
[breaking-change]