diff options
| author | Alex Crichton <alex@alexcrichton.com> | 2015-03-10 16:29:02 -0700 |
|---|---|---|
| committer | Alex Crichton <alex@alexcrichton.com> | 2015-03-17 18:03:03 -0700 |
| commit | aa88da63179b8ccd3b809e98b489c25199b06cf7 (patch) | |
| tree | f6252e734ef2c02e57ff1d39cfb7b64b145830f5 /src/libcollections/string.rs | |
| parent | c64d671671aea2e44ee7fc6eb00ee75fc30ed7b9 (diff) | |
| download | rust-aa88da63179b8ccd3b809e98b489c25199b06cf7.tar.gz rust-aa88da63179b8ccd3b809e98b489c25199b06cf7.zip | |
std: Tweak some unstable features of `str`
This commit clarifies some of the unstable features in the `str` module by moving them out of the blanket `core` and `collections` features. The following methods were moved to the `str_char` feature which generally encompasses decoding specific characters from a `str` and dealing with the result. It is unclear if any of these methods need to be stabilized for 1.0 and the most conservative route for now is to continue providing them but to leave them as unstable under a more specific name. * `is_char_boundary` * `char_at` * `char_range_at` * `char_at_reverse` * `char_range_at_reverse` * `slice_shift_char` The following methods were moved into the generic `unicode` feature as they are specifically enabled by the `unicode` crate itself. * `nfd_chars` * `nfkd_chars` * `nfc_chars` * `graphemes` * `grapheme_indices` * `width`
Diffstat (limited to 'src/libcollections/string.rs')
| -rw-r--r-- | src/libcollections/string.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/src/libcollections/string.rs b/src/libcollections/string.rs index d2bc98096f6..2a5f8db0496 100644 --- a/src/libcollections/string.rs +++ b/src/libcollections/string.rs @@ -29,7 +29,7 @@ use unicode::str as unicode_str; use unicode::str::Utf16Item; use borrow::{Cow, IntoCow}; -use str::{self, CharRange, FromStr, Utf8Error}; +use str::{self, FromStr, Utf8Error}; use vec::{DerefVec, Vec, as_vec}; /// A growable string stored as a UTF-8 encoded buffer. @@ -561,9 +561,9 @@ impl String { return None } - let CharRange {ch, next} = self.char_range_at_reverse(len); + let ch = self.char_at_reverse(len); unsafe { - self.vec.set_len(next); + self.vec.set_len(len - ch.len_utf8()); } Some(ch) } @@ -595,7 +595,8 @@ impl String { let len = self.len(); assert!(idx <= len); - let CharRange { ch, next } = self.char_range_at(idx); + let ch = self.char_at(idx); + let next = idx + ch.len_utf8(); unsafe { ptr::copy(self.vec.as_mut_ptr().offset(idx as isize), self.vec.as_ptr().offset(next as isize), |
