commit | 6a26efa8111b761f346ed9297b63057cf1dd96af | [log] [tgz] |
---|---|---|
author | Joel Galenson <jgalenson@google.com> | Tue Aug 24 19:30:16 2021 +0000 |
committer | Automerger Merge Worker <android-build-automerger-merge-worker@system.gserviceaccount.com> | Tue Aug 24 19:30:16 2021 +0000 |
tree | 629f0825c5a3b3f7870521f987b6ed3285cf101f | |
parent | 72e8661e14e15eff76042b92405b94a8435035b1 [diff] | |
parent | a044df2a370e3d2bb3db17527b33ef6ed3358e7e [diff] |
Update TEST_MAPPING am: 1fba4247aa am: 0ee26cefa5 am: a044df2a37 Original change: https://android-review.googlesource.com/c/platform/external/rust/crates/unicode-segmentation/+/1804436 Change-Id: I62c5267f325a36f6d98fba72b76089fe3852641b
Iterators which split strings on Grapheme Cluster or Word boundaries, according to the Unicode Standard Annex #29 rules.
use unicode_segmentation::UnicodeSegmentation; fn main() { let s = "a̐éö̲\r\n"; let g = s.graphemes(true).collect::<Vec<&str>>(); let b: &[_] = &["a̐", "é", "ö̲", "\r\n"]; assert_eq!(g, b); let s = "The quick (\"brown\") fox can't jump 32.3 feet, right?"; let w = s.unicode_words().collect::<Vec<&str>>(); let b: &[_] = &["The", "quick", "brown", "fox", "can't", "jump", "32.3", "feet", "right"]; assert_eq!(w, b); let s = "The quick (\"brown\") fox"; let w = s.split_word_bounds().collect::<Vec<&str>>(); let b: &[_] = &["The", " ", "quick", " ", "(", "\"", "brown", "\"", ")", " ", " ", "fox"]; assert_eq!(w, b); }
unicode-segmentation does not depend on libstd, so it can be used in crates with the #![no_std]
attribute.
You can use this package in your project by adding the following to your Cargo.toml
:
[dependencies] unicode-segmentation = "1.8.0"
GraphemeCursor
API allows random access and bidirectional iteration.as_str
methods to the iterator types.