Closed
Description
The str
type offers a number of char
-oriented methods, many of which can be replaced by uses of char_indices
.
It's not clear how widely used these methods are, or whether there are significant downsides over using char_indices
. This API area needs a comprehensive re-evaluation.
cc @SimonSapin
Metadata
Metadata
Assignees
Labels
Type
Projects
Milestone
Relationships
Development
No branches or pull requests
Activity
murarth commentedon Oct 29, 2015
This may be obvious, but I just want to point out that
is_char_boundary
is much more efficient than a solution involving iteration overchar_indices
. If nothing else under this feature gate is stabilized, I think at least this should method should be.SimonSapin commentedon Dec 28, 2015
I’ve used
str::is_char_boundary
in low-level string manipulation: rust-lang/rfcs#1432. In this case I’d like this functionality to move intostd
where stability is not a problem, but the fact remains thatis_char_boundary
is important in unsafe code dealing with strings.Now, most (all?) of its uses are inside
assert!
, which is possibly to do in stable Rust by relying on the side effect of some other operation. For example,s[..i];
is equivalent toassert!(s.is_char_boundary(i));
but it’s much less self-explanatory. It definitely needs a comment.I’d like to nominate
is_char_boundary
for stabilization. It’s needed internally anyway, so it’s not like it has extra maintenance cost.(I care less about the other
str_char
methods. I think they predate and are largely made obsolete by external iterators.)std::str::CharRange
be public? #9387huonw commentedon Jan 5, 2016
Some discussion about
CharRange
on #9387.aturon commentedon Jan 27, 2016
Nominating for discussion -- need a direction here.
dhardy commentedon Jan 27, 2016
I found a use for
is_char_boundary
recently, in order to implement a variant of truncate:on play.rust-lang.org
bluss commentedon Jan 27, 2016
is_char_boundary
is very useful, as soon as you implement your own low level string utils. I've replicated in stable rust for use as well.alexcrichton commentedon Jan 29, 2016
Unfortunately the libs team didn't get a chance to talk about this in terms of stabilization for 1.8, but I'm going to leave the nominated tag as I think we should chat about this regardless.
alexcrichton commentedon Feb 11, 2016
The libs team discussed this during triage today, and the conclusion was:
is_char_boundary
(definitely seems desired at least)21 remaining items