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_concat_ext` stabilization #27747
Comments
aturon
added
T-libs
B-unstable
labels
Aug 12, 2015
This comment has been minimized.
This comment has been minimized.
bfrog
commented
Nov 16, 2015
|
Having just run into needing this today it would be great to see the documentation for this referenced in the Vec docs with some examples |
This comment has been minimized.
This comment has been minimized.
|
@bfrog agreed. cc @steveklabnik |
This comment has been minimized.
This comment has been minimized.
|
/cc #29380 |
This comment has been minimized.
This comment has been minimized.
|
@aturon just reading along, and I'm curious if you have time to explain: What are the technical reasons you mentioned at the top? Is this related to why the |
This comment has been minimized.
This comment has been minimized.
|
So, the main problem with moving to inherent methods at this point is that the traits provide something akin to method overloading -- both apply to slice types varying only by some bounds ( re: If you're just using ... Hope that helps! |
This comment has been minimized.
This comment has been minimized.
|
Good to know :) |
This comment has been minimized.
This comment has been minimized.
Dr-Emann
commented
Apr 17, 2017
|
It's kinda annoying to be able to join strings with a str (which can have multiple chars), but joining a slice of slices, you can only join with a single element. e.g. let v = vec!["1", "2", "3"];
v.join(", ")works, but let v: Vec<&[u8]> = vec![b"1", b"2", b"3"];
v.join(b", ") // Error: expected u8, found array of 2 elements
v.join(&b',') // works, but is missing the space chardoesn't work |
Mark-Simulacrum
added
the
C-tracking-issue
label
Jul 22, 2017
This comment has been minimized.
This comment has been minimized.
|
I tried making the methods inherent with separate inherent impls. But we can't have multiple inherent impls for a primitive. I got the error: "only a single inherent implementation marked with This is known of course, the issue is #32631. |
This comment has been minimized.
This comment has been minimized.
|
@leodasvacas I think you mean multiple The libs team discussed this and consensus was to add Design proposals to generalize this functionality to iterators are welcome. |
This comment has been minimized.
This comment has been minimized.
sanmai-NL
commented
Sep 6, 2018
Does this mean |
This comment has been minimized.
This comment has been minimized.
|
@sanmai-NL That is correct. (Modulo #15702, which is a bug and not considered part of the stability promise.) |
This comment has been minimized.
This comment has been minimized.
|
Does there exist a path to stabilizing impl<S: Borrow<BStr>> SliceConcatExt for [S] {
type Output = BString;
// ...
}The work-around is to define a separate trait that is probably identical to |
aturon commentedAug 12, 2015
The SliceConcatExt trait offers methods
concatandjoinon slices. For somewhat technical reasons, it wasn't possible to make these inherent methods.The methods themselves are stable, but the trait isn't. However, since the trait is in the prelude, the methods are usable in stable today.
Ideally, the methods would also be available on iterators, but there are performance ramifications for doing so. Impl specialization may help.