Join GitHub today
GitHub is home to over 31 million developers working together to host and review code, manage projects, and build software together.
Sign upStabilize mutable slice API #17494
Conversation
This comment has been minimized.
This comment has been minimized.
aturon
force-pushed the
aturon:stabilize-mutable-slices
branch
from
2db3c9d
to
5307857
Sep 23, 2014
alexcrichton
reviewed
Sep 24, 2014
| @@ -778,10 +801,11 @@ pub trait MutableSlice<'a, T> { | |||
| /// // v.unsafe_set(10, "oops".to_string()); | |||
| /// } | |||
| /// ``` | |||
| #[deprecated = "use as_mut_ptr"] | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Sep 24, 2014
Member
This may also want to mention the set part as well:
#[deprecated = "use `*foo.as_mut_ptr().offset(index) = val`"]
alexcrichton
reviewed
Sep 24, 2014
| @@ -792,6 +816,7 @@ pub trait MutableSlice<'a, T> { | |||
| /// // memory leak! `"bar".to_string()` is not deallocated. | |||
| /// unsafe { v.init_elem(1, "baz".to_string()); } | |||
| /// ``` | |||
| #[deprecated = "use as_mut_ptr"] | |||
| unsafe fn init_elem(self, i: uint, val: T); | |||
This comment has been minimized.
This comment has been minimized.
alexcrichton
Sep 24, 2014
Member
#[deprecated = "use `ptr::write(foo.as_mut_ptr().offset(i), val)`"]
alexcrichton
reviewed
Sep 24, 2014
| @@ -799,6 +824,7 @@ pub trait MutableSlice<'a, T> { | |||
| /// This does not run destructors on the overwritten elements, and | |||
| /// ignores move semantics. `self` and `src` must not | |||
| /// overlap. Fails if `self` is shorter than `src`. | |||
| #[deprecated = "use as_mut_ptr"] | |||
| unsafe fn copy_memory(self, src: &[T]); | |||
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
Looks good to me! r=me with some adjustments to the deprecation messages. |
aturon
force-pushed the
aturon:stabilize-mutable-slices
branch
from
5307857
to
9834d45
Sep 24, 2014
bors
added a commit
that referenced
this pull request
Sep 25, 2014
bors
added a commit
that referenced
this pull request
Sep 25, 2014
bors
added a commit
that referenced
this pull request
Sep 25, 2014
bors
added a commit
that referenced
this pull request
Sep 25, 2014
aturon
added some commits
Sep 22, 2014
aturon
force-pushed the
aturon:stabilize-mutable-slices
branch
from
9834d45
to
c59ef66
Sep 26, 2014
This comment has been minimized.
This comment has been minimized.
|
r=alexcrichton |
thestinger
closed this
Sep 26, 2014
thestinger
reopened this
Sep 26, 2014
This comment has been minimized.
This comment has been minimized.
|
Why is this a regression for low-level Rust? |
This comment has been minimized.
This comment has been minimized.
|
This is a small change that affects two methods that are rarely used in the extant codebase. Nobody felt that it would be controversial and the implication that we were deliberately attempting to sidestep community consensus is incorrect. |
This comment has been minimized.
This comment has been minimized.
|
@thestinger Can you be more specific about how this is making unchecked indexing on slices harder? Discussion about this is happening now. |
This comment has been minimized.
This comment has been minimized.
|
@thestinger Do you have specific criticisms of the content of this pull request that you would like to discuss? |
This comment has been minimized.
This comment has been minimized.
|
I think the problem here is just a poor deprecation message. It should instead suggest: Replace |
Gankro
reviewed
Sep 26, 2014
| /// } | ||
| /// ``` | ||
| /// Deprecated: use `*foo.as_mut_ptr().offset(index) = val` instead. | ||
| #[deprecated = "use `*foo.as_mut_ptr().offset(index) = val`"] |
This comment has been minimized.
This comment has been minimized.
Gankro
Sep 26, 2014
Contributor
Isn't *foo.unsafe_mut(index) = val a better choice here?
Edit: ah, this was already stated elsewhere.
This comment has been minimized.
This comment has been minimized.
aturon
Sep 26, 2014
Author
Member
Yes -- see comment in the github thread above. This was just a mistake in the message.
This comment has been minimized.
This comment has been minimized.
|
As with many other deprecations (of safe APIs), these were eliminated as conveniences that weren't worth the extra API surface area. There's also a general push toward funneling conveniences through central traits/data structures, like If you want to do extensive unsafe work with slices, the simplest avenue would be to use It's also worth noting that deprecations like these don't entail never providing such conveniences in the future, if they are ultimately deemed worthwhile. But there has been a lot of accumulation of ad hoc APIs, and the stabilization process is trying to move things toward a somewhat minimalistic, consistent, coherent, clean, and reasonably ergonomic state heading toward 1.0. (For bigger changes, like conventions, or removing the collection traits, or consolidating the numerics hierarchy, this involves RFCs.) As an aside, we should consider adding an |
This comment has been minimized.
This comment has been minimized.
|
I still think it's a regression and I disagree with this process but I'm not interested in arguing about it anymore. I don't care enough about the standard library to deal with that. |
This comment has been minimized.
This comment has been minimized.
|
saw approval from alexcrichton |
This comment has been minimized.
This comment has been minimized.
|
merging aturon/rust/stabilize-mutable-slices = c59ef66 into auto |
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
fast-forwarding master to auto = 5d653c1 |
aturon commentedSep 23, 2014
This commit is another in the series of vector slice API stabilization. The focus here is the mutable slice API.
Largely, this API inherits the stability attributes previously assigned to the analogous methods on immutable slides. It also adds comments to a few
unstableattributes that were previously missing them.In addition, the commit adds several
_mutvariants of APIs that were missing:init_muthead_muttail_mutsplitn_mutrsplitn_mutSome of the unsafe APIs --
unsafe_set,init_elem, andcopy_memory-- were deprecated in favor of working throughas_mut_ptr, to simplify the API surface.Due to deprecations, this is a:
[breaking-change]