tag | 973dea7f78b25c338177af15293e977db57da32a | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Thu May 19 16:26:02 2022 -0700 |
object | 6411b4594228c03676662cc549074f130bf931d5 |
Platform Tools Release 33.0.1 (8253317)
commit | 6411b4594228c03676662cc549074f130bf931d5 | [log] [tgz] |
---|---|---|
author | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Mar 04 04:26:08 2022 +0000 |
committer | Android Build Coastguard Worker <android-build-coastguard-worker@google.com> | Fri Mar 04 04:26:08 2022 +0000 |
tree | ed23f02709b7a5c4ccfef074596728ff950fe78e | |
parent | 3cafbd4f6dd1923e6e1d56085700037e1f3f0f8f [diff] | |
parent | 0135332a115f3fc5992b9810113e827cdf27290f [diff] |
Snap for 8253222 from 0135332a115f3fc5992b9810113e827cdf27290f to sdk-release Change-Id: If4dc0af570f62192fd666e24ef0a2a7cecdb4476
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.9.0"
GraphemeCursor
API allows random access and bidirectional iteration.as_str
methods to the iterator types.