tag | a1d1f33254a77b9ab74f518f20d2d178865a960d | |
---|---|---|
tagger | Manish Goregaokar <manishsmail@gmail.com> | Sat Nov 09 18:04:02 2019 |
object | 637c9874c4fe0c205ff27787faf150a40295c6c3 |
v1.6.0
commit | 637c9874c4fe0c205ff27787faf150a40295c6c3 | [log] [tgz] |
---|---|---|
author | Manish Goregaokar <manishsmail@gmail.com> | Sat Nov 09 18:03:26 2019 |
committer | GitHub <noreply@github.com> | Sat Nov 09 18:03:26 2019 |
tree | e755f4b5fe8e7e940d61cbd6e27a7bf81b6722c5 | |
parent | 8b601c1388f6cd950d22bb409380a112f889a905 [diff] | |
parent | fc6c486b2fe51adb3552f23036e9b692d7b3ac96 [diff] |
Merge pull request #73 from unicode-rs/bump Bump to 1.6.0
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.