tag | a38b17ae8abe7ed4f0b21b9c843b17c572b367c0 | |
---|---|---|
tagger | The Android Open Source Project <initial-contribution@android.com> | Tue Jul 14 15:06:37 2020 -0700 |
object | a863f6773e9e44dfd7ee1d1875d4218016131cbc |
Android R Beta 2
commit | a863f6773e9e44dfd7ee1d1875d4218016131cbc | [log] [tgz] |
---|---|---|
author | Chih-Hung Hsieh <chh@google.com> | Tue Jul 07 11:50:53 2020 -0700 |
committer | Chih-Hung Hsieh <chh@google.com> | Tue Jul 07 11:59:10 2020 -0700 |
tree | 5d3554b4ec6cca5d60c7245b9ee977316664fa79 | |
parent | ed985d4a5a866c02a41fc9a7585bd8ebee30ed2a [diff] |
Add OWNERS Bug: 158624751 Test: make Change-Id: Iea654bc1685893c23c0cebbfc3316d2add21ed73
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 = UnicodeSegmentation::graphemes(s, 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.3.0"
GraphemeCursor
API allows random access and bidirectional iteration.as_str
methods to the iterator types.