juniper/unicode_bidi/index.html
Juniper Documentation Builder 95d942c9d4 Update documentation for Juniper
2016-09-11 18:41:24 +00:00

234 lines
No EOL
13 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!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="../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../main.css">
</head>
<body class="rustdoc">
<!--[if lte IE 8]>
<div class="warning">
This old browser is unsupported and will most likely display funky
things.
</div>
<![endif]-->
<nav class="sidebar">
<p class='location'></p><script>window.sidebarCurrent = {name: 'unicode_bidi', ty: 'mod', relpath: '../'};</script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press S to search, ? for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content mod">
<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'>&#x2212;</span>]
</a>
</span><a id='src-0' class='srclink' href='../src/unicode_bidi/lib.rs.html#10-1026' 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>
<pre class='rust rust-example-rendered'>
<span class='kw'>use</span> <span class='ident'>unicode_bidi</span>::{<span class='ident'>process_text</span>, <span class='ident'>reorder_line</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'>&quot;א&quot;</span>,
<span class='string'>&quot;ב&quot;</span>,
<span class='string'>&quot;ג&quot;</span>,
<span class='string'>&quot;a&quot;</span>,
<span class='string'>&quot;b&quot;</span>,
<span class='string'>&quot;c&quot;</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'>info</span> <span class='op'>=</span> <span class='ident'>process_text</span>(<span class='kw-2'>&amp;</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'>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'>paragraph_info</span> <span class='op'>=</span> <span class='kw-2'>&amp;</span><span class='ident'>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'>paragraph_info</span>.<span class='ident'>level</span>, <span class='number'>1</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&#39;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'>paragraph_info</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'>reorder_line</span>(<span class='kw-2'>&amp;</span><span class='ident'>text</span>, <span class='ident'>line</span>, <span class='kw-2'>&amp;</span><span class='ident'>info</span>.<span class='ident'>levels</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'>&quot;a&quot;</span>,
<span class='string'>&quot;b&quot;</span>,
<span class='string'>&quot;c&quot;</span>,
<span class='string'>&quot;ג&quot;</span>,
<span class='string'>&quot;ב&quot;</span>,
<span class='string'>&quot;א&quot;</span>]);</pre>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Reexports</a></h2>
<table><tr><td><code>pub use tables::{<a class='enum' href='../unicode_bidi/tables/enum.BidiClass.html' title='unicode_bidi::tables::BidiClass'>BidiClass</a>, <a class='fn' href='../unicode_bidi/tables/fn.bidi_class.html' title='unicode_bidi::tables::bidi_class'>bidi_class</a>, <a class='constant' href='../unicode_bidi/tables/constant.UNICODE_VERSION.html' title='unicode_bidi::tables::UNICODE_VERSION'>UNICODE_VERSION</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='tables/index.html'
title='unicode_bidi::tables'>tables</a></td>
<td class='docblock short'>
</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'>BidiInfo</a></td>
<td class='docblock short'>
<p>Output of <code>process_text</code></p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='struct' href='struct.InitialProperties.html'
title='unicode_bidi::InitialProperties'>InitialProperties</a></td>
<td class='docblock short'>
<p>Output of <code>initial_scan</code></p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='struct' href='struct.ParagraphInfo.html'
title='unicode_bidi::ParagraphInfo'>ParagraphInfo</a></td>
<td class='docblock short'>
<p>Info about a single paragraph</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.initial_scan.html'
title='unicode_bidi::initial_scan'>initial_scan</a></td>
<td class='docblock short'>
<p>Find the paragraphs and BidiClasses in a string of text.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.is_ltr.html'
title='unicode_bidi::is_ltr'>is_ltr</a></td>
<td class='docblock short'>
<p>Even embedding levels are left-to-right.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.is_rtl.html'
title='unicode_bidi::is_rtl'>is_rtl</a></td>
<td class='docblock short'>
<p>Odd levels are right-to-left.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.process_text.html'
title='unicode_bidi::process_text'>process_text</a></td>
<td class='docblock short'>
<p>Determine the bidirectional embedding levels for a single paragraph.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.reorder_line.html'
title='unicode_bidi::reorder_line'>reorder_line</a></td>
<td class='docblock short'>
<p>Re-order a line based on resolved levels.</p>
</td>
</tr>
<tr class=' module-item'>
<td><a class='fn' href='fn.visual_runs.html'
title='unicode_bidi::visual_runs'>visual_runs</a></td>
<td class='docblock short'>
<p>Find the level runs within a line and return them in visual order.</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'>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>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>&larrb;</dt>
<dd>Move up in search results</dd>
<dt>&rarrb;</dt>
<dd>Move down in search results</dd>
<dt>&#9166;</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../";
window.currentCrate = "unicode_bidi";
window.playgroundUrl = "";
</script>
<script src="../jquery.js"></script>
<script src="../main.js"></script>
<script defer src="../search-index.js"></script>
</body>
</html>