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 upTracking issue for slice::{ref_slice, mut_ref_slice} #27774
Comments
alexcrichton
added
T-libs
B-unstable
labels
Aug 12, 2015
alexcrichton
referenced this issue
Aug 13, 2015
Closed
Tracking issue for viewing Result/Option as slices #27776
This comment has been minimized.
This comment has been minimized.
|
Speaking personally, I love these functions. I don't need 'em often, but when I do, I'm happy I have them. =) |
alexcrichton
added
the
E-easy
label
Aug 13, 2015
This comment has been minimized.
This comment has been minimized.
|
Although they are (Compare with functionality that may be rarely used but is impossibly to reasonably implement outside of |
SimonSapin
referenced this issue
Aug 13, 2015
Closed
Tracking issue for `cell_extras` stabilization #27746
This comment has been minimized.
This comment has been minimized.
|
Nominating for 1.5 resolution (I'd personally want to deprecate) |
alexcrichton
added
the
I-nominated
label
Sep 17, 2015
This comment has been minimized.
This comment has been minimized.
|
It's a safe abstraction of unsafe code, I think it would be suited for the standard library. |
This comment has been minimized.
This comment has been minimized.
|
Just to be clear for where I use this (in case you don't know), it's in a situation like this. Often I have an enum where the variants have different numbers of things associated with them (let's say integers here). Sometimes it's handy to match and only have to deal with the exact right number of integers for each case, but other times I want to just walk over all the integers. For some reason, it often happens that the variants have either 0, 1, or N such things. This works out quite nicely:
This seems to come up semi-regularly for me. (Sadly, the methods that let you go from The other situation where this fn comes in handy for me is when you have some generic helper that takes a I think it's ok for this to live in libstd. It's not really duplicating anything else; I mean it's true you can write them in terms of other APIs, but only by dropping into unsafe code and going into a whole 'nother level of abstraction. (That said, if there were to be another crate that ALSO included the ability to convert tuples into slices and so forth, that's more interesting. Though that's probably something we can't "safely" do until we agree to commit to the way tuples are represented in memory, though I could never imagine us changing this.) |
This comment has been minimized.
This comment has been minimized.
|
This issue is now entering its cycle-long FCP for resolution in 1.5 The libs team was a little up in the air about deprecation or stabilization here, comments are certainly welcome! |
alexcrichton
added
final-comment-period
and removed
I-nominated
labels
Sep 24, 2015
This comment has been minimized.
This comment has been minimized.
|
|
This comment has been minimized.
This comment has been minimized.
|
Please stabilize these. Personally, I use them for reading single bytes from a reader (with |
This comment has been minimized.
This comment has been minimized.
briansmith
commented
Sep 25, 2015
|
The documentation says "Converts a pointer to A into a slice of length 1 (without copying)." Shouldn't "pointer" be "reference"? |
SimonSapin
added a commit
to SimonSapin/rust
that referenced
this issue
Sep 25, 2015
SimonSapin
referenced this issue
Sep 25, 2015
Merged
Docs: &A and &mut A are references, not pointers #28652
This comment has been minimized.
This comment has been minimized.
|
Yes. |
steveklabnik
added a commit
to steveklabnik/rust
that referenced
this issue
Sep 25, 2015
steveklabnik
added this to the 1.5 milestone
Oct 1, 2015
Manishearth
removed
the
E-easy
label
Oct 2, 2015
This comment has been minimized.
This comment has been minimized.
|
Definitely stabilize. Don't force me to use |
This comment has been minimized.
This comment has been minimized.
photino
commented
Oct 21, 2015
|
Personally, I would like to see that they are deprecated. They are simple wrappers of the unsafe code but not marked as |
This comment has been minimized.
This comment has been minimized.
|
@photino They are not marked This is absolutely consistent and is actually a very concise example of a core Rust idiom: that safe wrappers can be created around |
This comment has been minimized.
This comment has been minimized.
photino
commented
Oct 21, 2015
|
@cybergeek94 Thanks for your explanation. I can't figure out any other reasons for not providing such safe wrappers. |
This comment has been minimized.
This comment has been minimized.
|
The libs team discussed this during triage today and the decision was to deprecate these functions. The standard library currently doesn't house many nuggets of functionality like this (e.g. see the recent discussions around While certainly useful from time to time, it's not clear that these functions belong in the standard library right now. There can always be a helper crate implementing all sorts of conversions like this, however! |
This comment has been minimized.
This comment has been minimized.
|
That seems like a really weird decision. This is such a fundamental conversion between primitive datatypes it probably belongs at the language level (ie. What does it matter if people only need it from time to time? It's such a trivial function it's not like it's adding bloat. |
This comment has been minimized.
This comment has been minimized.
|
I mean it's like saying "Oh sure you can parse the file table of a fat32 drive out-of-the-box but if you want to upcast a |
This comment has been minimized.
This comment has been minimized.
|
My opinion was also informed by a conversation with Paul Pedriana, who said /me disappointed by decision to remove On Fri, Oct 23, 2015 at 4:04 AM, Vadim Petrochenkov <
|
This comment has been minimized.
This comment has been minimized.
|
If anyone still wants these functions, I put them in a small crate: https://crates.io/crates/ref_slice |
This comment has been minimized.
This comment has been minimized.
|
Will we specify that |
This comment has been minimized.
This comment has been minimized.
|
The lang team decided that |
This comment has been minimized.
This comment has been minimized.
|
@huonw Do you have a link to that decision? |
This comment has been minimized.
This comment has been minimized.
|
That crate and its documentation. (You might be able to get the actual things that were written down at the time in the lang team meeting minutes somewhere in July or August, but I don't think they'll offer anything more than that link.) |
alexcrichton
added a commit
to alexcrichton/rust
that referenced
this issue
Oct 23, 2015
This comment has been minimized.
This comment has been minimized.
|
@steveklabnik Thanks for the crate. |
bors
added a commit
that referenced
this issue
Oct 24, 2015
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
This comment has been minimized.
|
@notriddle Thanks. |
This comment has been minimized.
This comment has been minimized.
|
NB. that discussion isn't the lang team (I believe it was an independent invention of the same idea). The notes that were taken are at the end of https://github.com/rust-lang/meeting-minutes/blob/master/lang-team/2015-07-23.md |
This comment has been minimized.
This comment has been minimized.
|
@huonw Thank you, I tried finding them, but I didn't. |
alexcrichton commentedAug 12, 2015
This is a tracking issue for the unstable
ref_slicefeature in the standard library. These functions seem fairly innocuous but it's also somewhat questionable how useful they are. They're probably ready for either stabilization or deprecation as-is.cc @nikomatsakis