blob: bac00e16e263f40ca763896b539d300969f3eed0 [file] [log] [blame]
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="Iterators which split strings on Grapheme Cluster, Word or Sentence boundaries, according to the Unicode Standard Annex #29 rules."><meta name="keywords" content="rust, rustlang, rust-lang, unicode_segmentation"><title>unicode_segmentation - Rust</title><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Regular.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../FiraSans-Medium.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Regular.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceSerif4-Bold.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../SourceCodePro-Semibold.ttf.woff2"><link rel="stylesheet" href="../normalize.css"><link rel="stylesheet" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" href="../ayu.css" disabled><link rel="stylesheet" href="../dark.css" disabled><link rel="stylesheet" href="../light.css" id="themeStyle"><script id="default-settings" ></script><script src="../storage.js"></script><script defer src="../crates.js"></script><script defer src="../main.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" href="https://unicode-rs.github.io/unicode-rs_sm.png"></head><body class="rustdoc mod crate"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle">&#9776;</button><a class="sidebar-logo" href="../unicode_segmentation/index.html"><div class="logo-container"><img src="https://unicode-rs.github.io/unicode-rs_sm.png" alt="logo"></div></a><h2></h2></nav><nav class="sidebar"><a class="sidebar-logo" href="../unicode_segmentation/index.html"><div class="logo-container">
<img src="https://unicode-rs.github.io/unicode-rs_sm.png" alt="logo"></div></a><h2 class="location"><a href="#">Crate unicode_segmentation</a></h2><div class="sidebar-elems"><ul class="block"><li class="version">Version 1.10.1</li><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#traits">Traits</a></li></ul></section></div></nav><main><div class="width-limiter"><nav class="sub"><form class="search-form"><div class="search-container"><span></span><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" title="help" tabindex="-1"><a href="../help.html">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../wheel.svg"></a></div></div></form></nav><section id="main-content" class="content"><div class="main-heading"><h1 class="fqn">Crate <a class="mod" href="#">unicode_segmentation</a><button id="copy-path" onclick="copy_path(this)" title="Copy item path to clipboard"><img src="../clipboard.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="srclink" href="../src/unicode_segmentation/lib.rs.html#11-307">source</a> · <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span></div><details class="rustdoc-toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>Iterators which split strings on Grapheme Cluster, Word or Sentence boundaries, according
to the <a href="http://www.unicode.org/reports/tr29/">Unicode Standard Annex #29</a> rules.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">extern crate </span>unicode_segmentation;
<span class="kw">use </span>unicode_segmentation::UnicodeSegmentation;
<span class="kw">fn </span>main() {
<span class="kw">let </span>s = <span class="string">&quot;a̐éö̲\r\n&quot;</span>;
<span class="kw">let </span>g = UnicodeSegmentation::graphemes(s, <span class="bool-val">true</span>).collect::&lt;Vec&lt;<span class="kw-2">&amp;</span>str&gt;&gt;();
<span class="kw">let </span>b: <span class="kw-2">&amp;</span>[<span class="kw">_</span>] = <span class="kw-2">&amp;</span>[<span class="string">&quot;a̐&quot;</span>, <span class="string">&quot;é&quot;</span>, <span class="string">&quot;ö̲&quot;</span>, <span class="string">&quot;\r\n&quot;</span>];
<span class="macro">assert_eq!</span>(g, b);
<span class="kw">let </span>s = <span class="string">&quot;The quick (\&quot;brown\&quot;) fox can&#39;t jump 32.3 feet, right?&quot;</span>;
<span class="kw">let </span>w = s.unicode_words().collect::&lt;Vec&lt;<span class="kw-2">&amp;</span>str&gt;&gt;();
<span class="kw">let </span>b: <span class="kw-2">&amp;</span>[<span class="kw">_</span>] = <span class="kw-2">&amp;</span>[<span class="string">&quot;The&quot;</span>, <span class="string">&quot;quick&quot;</span>, <span class="string">&quot;brown&quot;</span>, <span class="string">&quot;fox&quot;</span>, <span class="string">&quot;can&#39;t&quot;</span>, <span class="string">&quot;jump&quot;</span>, <span class="string">&quot;32.3&quot;</span>, <span class="string">&quot;feet&quot;</span>, <span class="string">&quot;right&quot;</span>];
<span class="macro">assert_eq!</span>(w, b);
<span class="kw">let </span>s = <span class="string">&quot;The quick (\&quot;brown\&quot;) fox&quot;</span>;
<span class="kw">let </span>w = s.split_word_bounds().collect::&lt;Vec&lt;<span class="kw-2">&amp;</span>str&gt;&gt;();
<span class="kw">let </span>b: <span class="kw-2">&amp;</span>[<span class="kw">_</span>] = <span class="kw-2">&amp;</span>[<span class="string">&quot;The&quot;</span>, <span class="string">&quot; &quot;</span>, <span class="string">&quot;quick&quot;</span>, <span class="string">&quot; &quot;</span>, <span class="string">&quot;(&quot;</span>, <span class="string">&quot;\&quot;&quot;</span>, <span class="string">&quot;brown&quot;</span>, <span class="string">&quot;\&quot;&quot;</span>, <span class="string">&quot;)&quot;</span>, <span class="string">&quot; &quot;</span>, <span class="string">&quot;fox&quot;</span>];
<span class="macro">assert_eq!</span>(w, b);
}</code></pre></div>
<h2 id="no_std"><a href="#no_std">no_std</a></h2>
<p>unicode-segmentation does not depend on libstd, so it can be used in crates
with the <code>#![no_std]</code> attribute.</p>
<h2 id="cratesio"><a href="#cratesio">crates.io</a></h2>
<p>You can use this package in your project by adding the following
to your <code>Cargo.toml</code>:</p>
<div class="example-wrap"><pre class="language-toml"><code>[dependencies]
unicode-segmentation = &quot;1.9.0&quot;</code></pre></div></div></details><h2 id="structs" class="small-section-header"><a href="#structs">Structs</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.GraphemeCursor.html" title="unicode_segmentation::GraphemeCursor struct">GraphemeCursor</a></div><div class="item-right docblock-short">Cursor-based segmenter for grapheme clusters.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.GraphemeIndices.html" title="unicode_segmentation::GraphemeIndices struct">GraphemeIndices</a></div><div class="item-right docblock-short">External iterator for grapheme clusters and byte offsets.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.Graphemes.html" title="unicode_segmentation::Graphemes struct">Graphemes</a></div><div class="item-right docblock-short">External iterator for a string’s
<a href="http://www.unicode.org/reports/tr29/#Grapheme_Cluster_Boundaries">grapheme clusters</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.USentenceBoundIndices.html" title="unicode_segmentation::USentenceBoundIndices struct">USentenceBoundIndices</a></div><div class="item-right docblock-short">External iterator for sentence boundaries and byte offsets.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.USentenceBounds.html" title="unicode_segmentation::USentenceBounds struct">USentenceBounds</a></div><div class="item-right docblock-short">External iterator for a string’s
<a href="http://www.unicode.org/reports/tr29/#Sentence_Boundaries">sentence boundaries</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UWordBoundIndices.html" title="unicode_segmentation::UWordBoundIndices struct">UWordBoundIndices</a></div><div class="item-right docblock-short">External iterator for word boundaries and byte offsets.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UWordBounds.html" title="unicode_segmentation::UWordBounds struct">UWordBounds</a></div><div class="item-right docblock-short">External iterator for a string’s
<a href="http://www.unicode.org/reports/tr29/#Word_Boundaries">word boundaries</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UnicodeSentences.html" title="unicode_segmentation::UnicodeSentences struct">UnicodeSentences</a></div><div class="item-right docblock-short">An iterator over the substrings of a string which, after splitting the string on
<a href="http://www.unicode.org/reports/tr29/#Sentence_Boundaries">sentence boundaries</a>,
contain any characters with the
<a href="http://unicode.org/reports/tr44/#Alphabetic">Alphabetic</a>
property, or with
<a href="http://unicode.org/reports/tr44/#General_Category_Values">General_Category=Number</a>.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UnicodeWordIndices.html" title="unicode_segmentation::UnicodeWordIndices struct">UnicodeWordIndices</a></div><div class="item-right docblock-short">An iterator over the substrings of a string which, after splitting the string on
<a href="http://www.unicode.org/reports/tr29/#Word_Boundaries">word boundaries</a>,
contain any characters with the
<a href="http://unicode.org/reports/tr44/#Alphabetic">Alphabetic</a>
property, or with
<a href="http://unicode.org/reports/tr44/#General_Category_Values">General_Category=Number</a>.
This iterator also provides the byte offsets for each substring.</div></div><div class="item-row"><div class="item-left module-item"><a class="struct" href="struct.UnicodeWords.html" title="unicode_segmentation::UnicodeWords struct">UnicodeWords</a></div><div class="item-right docblock-short">An iterator over the substrings of a string which, after splitting the string on
<a href="http://www.unicode.org/reports/tr29/#Word_Boundaries">word boundaries</a>,
contain any characters with the
<a href="http://unicode.org/reports/tr44/#Alphabetic">Alphabetic</a>
property, or with
<a href="http://unicode.org/reports/tr44/#General_Category_Values">General_Category=Number</a>.</div></div></div><h2 id="enums" class="small-section-header"><a href="#enums">Enums</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="enum" href="enum.GraphemeIncomplete.html" title="unicode_segmentation::GraphemeIncomplete enum">GraphemeIncomplete</a></div><div class="item-right docblock-short">An error return indicating that not enough content was available in the
provided chunk to satisfy the query, and that more content must be provided.</div></div></div><h2 id="constants" class="small-section-header"><a href="#constants">Constants</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="constant" href="constant.UNICODE_VERSION.html" title="unicode_segmentation::UNICODE_VERSION constant">UNICODE_VERSION</a></div><div class="item-right docblock-short">The version of <a href="http://www.unicode.org/">Unicode</a>
that this version of unicode-segmentation is based on.</div></div></div><h2 id="traits" class="small-section-header"><a href="#traits">Traits</a></h2><div class="item-table"><div class="item-row"><div class="item-left module-item"><a class="trait" href="trait.UnicodeSegmentation.html" title="unicode_segmentation::UnicodeSegmentation trait">UnicodeSegmentation</a></div><div class="item-right docblock-short">Methods for segmenting strings according to
<a href="http://www.unicode.org/reports/tr29/">Unicode Standard Annex #29</a>.</div></div></div></section></div></main><div id="rustdoc-vars" data-root-path="../" data-current-crate="unicode_segmentation" data-themes="ayu,dark,light" data-resource-suffix="" data-rustdoc-version="1.66.0-nightly (5c8bff74b 2022-10-21)" ></div></body></html>