mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-22 16:08:24 +00:00
58 lines
13 KiB
HTML
58 lines
13 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="This crate implements the Unicode Bidirectional Algorithm for display of mixed right-to-left and left-to-right text. It is written in safe Rust, compatible with the current stable release."><title>unicode_bidi - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="unicode_bidi" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="../crates.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></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" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../unicode_bidi/index.html">unicode_bidi</a><span class="version">0.3.15</span></h2></div><div class="sidebar-elems"><ul class="block"><li><a id="all-types" href="all.html">All Items</a></li></ul><section><ul class="block"><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="#traits">Traits</a></li><li><a href="#functions">Functions</a></li><li><a href="#types">Type Aliases</a></li></ul></section></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Crate <a class="mod" href="#">unicode_bidi</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/unicode_bidi/lib.rs.html#10-2242">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><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>
|
|
<h3 id="example"><a class="doc-anchor" href="#example">§</a>Example</h3>
|
|
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>unicode_bidi::BidiInfo;
|
|
|
|
<span class="comment">// This example text is defined using `concat!` because some browsers
|
|
// and text editors have trouble displaying bidi strings.
|
|
</span><span class="kw">let </span>text = <span class="macro">concat!</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
|
|
// paragraph level automatically.
|
|
</span><span class="kw">let </span>bidi_info = BidiInfo::new(<span class="kw-2">&</span>text, <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>(bidi_info.paragraphs.len(), <span class="number">1</span>);
|
|
<span class="kw">let </span>para = <span class="kw-2">&</span>bidi_info.paragraphs[<span class="number">0</span>];
|
|
<span class="macro">assert_eq!</span>(para.level.number(), <span class="number">1</span>);
|
|
<span class="macro">assert_eq!</span>(para.level.is_rtl(), <span class="bool-val">true</span>);
|
|
|
|
<span class="comment">// Re-ordering is done after wrapping each paragraph into a sequence of
|
|
// lines. For this example, I'll just use a single line that spans the
|
|
// entire paragraph.
|
|
</span><span class="kw">let </span>line = para.range.clone();
|
|
|
|
<span class="kw">let </span>display = bidi_info.reorder_line(para, line);
|
|
<span class="macro">assert_eq!</span>(display, <span class="macro">concat!</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>,
|
|
]);</code></pre></div>
|
|
<h2 id="features"><a class="doc-anchor" href="#features">§</a>Features</h2>
|
|
<ul>
|
|
<li><code>std</code>: Enabled by default, but can be disabled to make <code>unicode_bidi</code>
|
|
<code>#![no_std]</code> + <code>alloc</code> compatible.</li>
|
|
<li><code>hardcoded-data</code>: Enabled by default. Includes hardcoded Unicode bidi data and more convenient APIs.</li>
|
|
<li><code>serde</code>: Adds [<code>serde::Serialize</code>] and [<code>serde::Deserialize</code>]
|
|
implementations to relevant types.</li>
|
|
</ul>
|
|
</div></details><h2 id="reexports" class="section-header">Re-exports<a href="#reexports" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name" id="reexport.BidiDataSource"><code>pub use crate::data_source::<a class="trait" href="data_source/trait.BidiDataSource.html" title="trait unicode_bidi::data_source::BidiDataSource">BidiDataSource</a>;</code></div></li><li><div class="item-name" id="reexport.Level"><code>pub use crate::level::<a class="struct" href="level/struct.Level.html" title="struct unicode_bidi::level::Level">Level</a>;</code></div></li><li><div class="item-name" id="reexport.LTR_LEVEL"><code>pub use crate::level::<a class="constant" href="level/constant.LTR_LEVEL.html" title="constant unicode_bidi::level::LTR_LEVEL">LTR_LEVEL</a>;</code></div></li><li><div class="item-name" id="reexport.RTL_LEVEL"><code>pub use crate::level::<a class="constant" href="level/constant.RTL_LEVEL.html" title="constant unicode_bidi::level::RTL_LEVEL">RTL_LEVEL</a>;</code></div></li></ul><h2 id="modules" class="section-header">Modules<a href="#modules" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="mod" href="data_source/index.html" title="mod unicode_bidi::data_source">data_source</a></div></li><li><div class="item-name"><a class="mod" href="deprecated/index.html" title="mod unicode_bidi::deprecated">deprecated</a></div><div class="desc docblock-short">This module holds deprecated assets only.</div></li><li><div class="item-name"><a class="mod" href="format_chars/index.html" title="mod unicode_bidi::format_chars">format_chars</a></div><div class="desc docblock-short">Directional Formatting Characters</div></li><li><div class="item-name"><a class="mod" href="level/index.html" title="mod unicode_bidi::level">level</a></div><div class="desc docblock-short">Bidi Embedding Level</div></li><li><div class="item-name"><a class="mod" href="utf16/index.html" title="mod unicode_bidi::utf16">utf16</a></div></li></ul><h2 id="structs" class="section-header">Structs<a href="#structs" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="struct" href="struct.BidiInfo.html" title="struct unicode_bidi::BidiInfo">BidiInfo</a></div><div class="desc docblock-short">Bidi information of the text.</div></li><li><div class="item-name"><a class="struct" href="struct.HardcodedBidiData.html" title="struct unicode_bidi::HardcodedBidiData">HardcodedBidiData</a></div><div class="desc docblock-short">Hardcoded Bidi data that ships with the unicode-bidi crate.</div></li><li><div class="item-name"><a class="struct" href="struct.InitialInfo.html" title="struct unicode_bidi::InitialInfo">InitialInfo</a></div><div class="desc docblock-short">Initial bidi information of the text.</div></li><li><div class="item-name"><a class="struct" href="struct.Paragraph.html" title="struct unicode_bidi::Paragraph">Paragraph</a></div><div class="desc docblock-short">Contains a reference of <code>BidiInfo</code> and one of its <code>paragraphs</code>.
|
|
And it supports all operation in the <code>Paragraph</code> that needs also its
|
|
<code>BidiInfo</code> such as <code>direction</code>.</div></li><li><div class="item-name"><a class="struct" href="struct.ParagraphBidiInfo.html" title="struct unicode_bidi::ParagraphBidiInfo">ParagraphBidiInfo</a></div><div class="desc docblock-short">Bidi information of text treated as a single paragraph.</div></li><li><div class="item-name"><a class="struct" href="struct.ParagraphInfo.html" title="struct unicode_bidi::ParagraphInfo">ParagraphInfo</a></div><div class="desc docblock-short">Bidi information about a single paragraph</div></li><li><div class="item-name"><a class="struct" href="struct.Utf8IndexLenIter.html" title="struct unicode_bidi::Utf8IndexLenIter">Utf8IndexLenIter</a></div><div class="desc docblock-short">Iterator over (UTF-8) string slices returning (index, char_len) tuple.</div></li></ul><h2 id="enums" class="section-header">Enums<a href="#enums" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="enum" href="enum.BidiClass.html" title="enum unicode_bidi::BidiClass">BidiClass</a></div><div class="desc docblock-short">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>.</div></li><li><div class="item-name"><a class="enum" href="enum.Direction.html" title="enum unicode_bidi::Direction">Direction</a></div></li></ul><h2 id="constants" class="section-header">Constants<a href="#constants" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="constant" href="constant.UNICODE_VERSION.html" title="constant unicode_bidi::UNICODE_VERSION">UNICODE_VERSION</a></div><div class="desc docblock-short">The <a href="http://www.unicode.org/versions/">Unicode version</a> of data</div></li></ul><h2 id="traits" class="section-header">Traits<a href="#traits" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="trait" href="trait.TextSource.html" title="trait unicode_bidi::TextSource">TextSource</a></div><div class="desc docblock-short">Trait that abstracts over a text source for use by the bidi algorithms.
|
|
We implement this for str (UTF-8) and for <a href="https://doc.rust-lang.org/1.80.0/std/primitive.u16.html" title="primitive u16">u16</a> (UTF-16, native-endian).
|
|
(For internal unicode-bidi use; API may be unstable.)
|
|
This trait is sealed and cannot be implemented for types outside this crate.</div></li></ul><h2 id="functions" class="section-header">Functions<a href="#functions" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="fn" href="fn.bidi_class.html" title="fn unicode_bidi::bidi_class">bidi_class</a></div><div class="desc docblock-short">Find the <code>BidiClass</code> of a single char.</div></li><li><div class="item-name"><a class="fn" href="fn.get_base_direction.html" title="fn unicode_bidi::get_base_direction">get_base_direction</a></div><div class="desc docblock-short">Get the base direction of the text provided according to the Unicode Bidirectional Algorithm.</div></li><li><div class="item-name"><a class="fn" href="fn.get_base_direction_full.html" title="fn unicode_bidi::get_base_direction_full">get_base_direction_full</a></div><div class="desc docblock-short">Get the base direction of the text provided according to the Unicode Bidirectional Algorithm,
|
|
considering the full text if the first paragraph is all-neutral.</div></li><li><div class="item-name"><a class="fn" href="fn.get_base_direction_full_with_data_source.html" title="fn unicode_bidi::get_base_direction_full_with_data_source">get_base_direction_full_with_data_source</a></div></li><li><div class="item-name"><a class="fn" href="fn.get_base_direction_with_data_source.html" title="fn unicode_bidi::get_base_direction_with_data_source">get_base_direction_with_data_source</a></div></li></ul><h2 id="types" class="section-header">Type Aliases<a href="#types" class="anchor">§</a></h2><ul class="item-table"><li><div class="item-name"><a class="type" href="type.LevelRun.html" title="type unicode_bidi::LevelRun">LevelRun</a></div><div class="desc docblock-short">A maximal substring of characters with the same embedding level.</div></li></ul></section></div></main></body></html> |