66 lines
11 KiB
HTML
66 lines
11 KiB
HTML
<!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="API documentation for the Rust `unicode_bidi` crate."><meta name="keywords" content="rust, rustlang, rust-lang, unicode_bidi"><title>unicode_bidi - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
|
||
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
|
||
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc mod"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">☰</div><a href='../unicode_bidi/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate unicode_bidi</p><div class="block version"><p>Version 0.3.4</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all unicode_bidi's items</p></a><div class="block items"><ul><li><a href="#reexports">Re-exports</a></li><li><a href="#modules">Modules</a></li><li><a href="#structs">Structs</a></li><li><a href="#enums">Enums</a></li><li><a href="#constants">Constants</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Definitions</a></li></ul></div><p class="location"></p><div id="sidebar-vars" data-name="unicode_bidi" data-ty="mod" data-relpath="../"></div></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"></div><button type="button" class="help-button">?</button>
|
||
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Crate <a class="mod" href="">unicode_bidi</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">−</span>]</a></span><a class="srclink" href="../src/unicode_bidi/lib.rs.html#10-890" title="goto source code">[src]</a></span></h1><div class="docblock"><p>This crate implements the <a href="http://www.unicode.org/reports/tr9/">Unicode Bidirectional Algorithm</a> for display of mixed
|
||
right-to-left and left-to-right text. It is written in safe Rust, compatible with the
|
||
current stable release.</p>
|
||
<h2 id="example" class="section-header"><a href="#example">Example</a></h2>
|
||
<div class="example-wrap"><pre class="rust rust-example-rendered">
|
||
<span class="kw">use</span> <span class="ident">unicode_bidi</span>::<span class="ident">BidiInfo</span>;
|
||
|
||
<span class="comment">// This example text is defined using `concat!` because some browsers</span>
|
||
<span class="comment">// and text editors have trouble displaying bidi strings.</span>
|
||
<span class="kw">let</span> <span class="ident">text</span> <span class="op">=</span> <span class="macro">concat</span><span class="macro">!</span>[
|
||
<span class="string">"א"</span>,
|
||
<span class="string">"ב"</span>,
|
||
<span class="string">"ג"</span>,
|
||
<span class="string">"a"</span>,
|
||
<span class="string">"b"</span>,
|
||
<span class="string">"c"</span>,
|
||
];
|
||
|
||
<span class="comment">// Resolve embedding levels within the text. Pass `None` to detect the</span>
|
||
<span class="comment">// paragraph level automatically.</span>
|
||
<span class="kw">let</span> <span class="ident">bidi_info</span> <span class="op">=</span> <span class="ident">BidiInfo</span>::<span class="ident">new</span>(<span class="kw-2">&</span><span class="ident">text</span>, <span class="prelude-val">None</span>);
|
||
|
||
<span class="comment">// This paragraph has embedding level 1 because its first strong character is RTL.</span>
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">bidi_info</span>.<span class="ident">paragraphs</span>.<span class="ident">len</span>(), <span class="number">1</span>);
|
||
<span class="kw">let</span> <span class="ident">para</span> <span class="op">=</span> <span class="kw-2">&</span><span class="ident">bidi_info</span>.<span class="ident">paragraphs</span>[<span class="number">0</span>];
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">para</span>.<span class="ident">level</span>.<span class="ident">number</span>(), <span class="number">1</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">para</span>.<span class="ident">level</span>.<span class="ident">is_rtl</span>(), <span class="bool-val">true</span>);
|
||
|
||
<span class="comment">// Re-ordering is done after wrapping each paragraph into a sequence of</span>
|
||
<span class="comment">// lines. For this example, I'll just use a single line that spans the</span>
|
||
<span class="comment">// entire paragraph.</span>
|
||
<span class="kw">let</span> <span class="ident">line</span> <span class="op">=</span> <span class="ident">para</span>.<span class="ident">range</span>.<span class="ident">clone</span>();
|
||
|
||
<span class="kw">let</span> <span class="ident">display</span> <span class="op">=</span> <span class="ident">bidi_info</span>.<span class="ident">reorder_line</span>(<span class="ident">para</span>, <span class="ident">line</span>);
|
||
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">display</span>, <span class="macro">concat</span><span class="macro">!</span>[
|
||
<span class="string">"a"</span>,
|
||
<span class="string">"b"</span>,
|
||
<span class="string">"c"</span>,
|
||
<span class="string">"ג"</span>,
|
||
<span class="string">"ב"</span>,
|
||
<span class="string">"א"</span>,
|
||
]);</pre></div>
|
||
</div><h2 id="reexports" class="section-header"><a href="#reexports">Re-exports</a></h2>
|
||
<table><tr><td><code>pub use level::<a class="struct" href="../unicode_bidi/level/struct.Level.html" title="struct unicode_bidi::level::Level">Level</a>;</code></td></tr><tr><td><code>pub use level::<a class="constant" href="../unicode_bidi/level/constant.LTR_LEVEL.html" title="constant unicode_bidi::level::LTR_LEVEL">LTR_LEVEL</a>;</code></td></tr><tr><td><code>pub use level::<a class="constant" href="../unicode_bidi/level/constant.RTL_LEVEL.html" title="constant unicode_bidi::level::RTL_LEVEL">RTL_LEVEL</a>;</code></td></tr></table><h2 id="modules" class="section-header"><a href="#modules">Modules</a></h2>
|
||
<table><tr class="module-item"><td><a class="mod" href="deprecated/index.html" title="unicode_bidi::deprecated mod">deprecated</a></td><td class="docblock-short"><p>This module holds deprecated assets only.</p>
|
||
</td></tr><tr class="module-item"><td><a class="mod" href="format_chars/index.html" title="unicode_bidi::format_chars mod">format_chars</a></td><td class="docblock-short"><p>Directional Formatting Characters</p>
|
||
</td></tr><tr class="module-item"><td><a class="mod" href="level/index.html" title="unicode_bidi::level mod">level</a></td><td class="docblock-short"><p>Bidi Embedding Level</p>
|
||
</td></tr></table><h2 id="structs" class="section-header"><a href="#structs">Structs</a></h2>
|
||
<table><tr class="module-item"><td><a class="struct" href="struct.BidiInfo.html" title="unicode_bidi::BidiInfo struct">BidiInfo</a></td><td class="docblock-short"><p>Bidi information of the text.</p>
|
||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.InitialInfo.html" title="unicode_bidi::InitialInfo struct">InitialInfo</a></td><td class="docblock-short"><p>Initial bidi information of the text.</p>
|
||
</td></tr><tr class="module-item"><td><a class="struct" href="struct.ParagraphInfo.html" title="unicode_bidi::ParagraphInfo struct">ParagraphInfo</a></td><td class="docblock-short"><p>Bidi information about a single paragraph</p>
|
||
</td></tr></table><h2 id="enums" class="section-header"><a href="#enums">Enums</a></h2>
|
||
<table><tr class="module-item"><td><a class="enum" href="enum.BidiClass.html" title="unicode_bidi::BidiClass enum">BidiClass</a></td><td class="docblock-short"><p>Represents values of the Unicode character property
|
||
<a href="http://www.unicode.org/reports/tr44/#Bidi_Class"><code>Bidi_Class</code></a>, also
|
||
known as the <em>bidirectional character type</em>.</p>
|
||
</td></tr></table><h2 id="constants" class="section-header"><a href="#constants">Constants</a></h2>
|
||
<table><tr class="module-item"><td><a class="constant" href="constant.UNICODE_VERSION.html" title="unicode_bidi::UNICODE_VERSION constant">UNICODE_VERSION</a></td><td class="docblock-short"><p>The <a href="http://www.unicode.org/versions/">Unicode version</a> of data</p>
|
||
</td></tr></table><h2 id="functions" class="section-header"><a href="#functions">Functions</a></h2>
|
||
<table><tr class="module-item"><td><a class="fn" href="fn.bidi_class.html" title="unicode_bidi::bidi_class fn">bidi_class</a></td><td class="docblock-short"><p>Find the <code>BidiClass</code> of a single char.</p>
|
||
</td></tr></table><h2 id="types" class="section-header"><a href="#types">Type Definitions</a></h2>
|
||
<table><tr class="module-item"><td><a class="type" href="type.LevelRun.html" title="unicode_bidi::LevelRun type">LevelRun</a></td><td class="docblock-short"><p>A maximal substring of characters with the same embedding level.</p>
|
||
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="unicode_bidi"></div>
|
||
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html> |