Files
2021-03-09 19:32:53 +00:00

32 lines
6.7 KiB
HTML
Raw Permalink 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 `ntext` crate."><meta name="keywords" content="rust, rustlang, rust-lang, ntext"><title>ntext - 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">&#9776;</div><a href='../ntext/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Crate ntext</p><div class="block version"><p>Version 0.2.1</p></div><div class="sidebar-elems"><a id="all-types" href="all.html"><p>See all ntext's items</p></a><div class="block items"><ul><li><a href="#macros">Macros</a></li><li><a href="#structs">Structs</a></li><li><a href="#functions">Functions</a></li></ul></div><p class="location"></p><script>window.sidebarCurrent = {name: "ntext", ty: "mod", relpath: "../"};</script></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="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 class="srclink" href="../src/ntext/lib.rs.html#1-40" title="goto source code">[src]</a></span><span class="in-band">Crate <a class="mod" href="">ntext</a></span></h1><div class="docblock"><p>Example program with default formatting</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">ntext</span>;
<span class="kw">use</span> <span class="ident">ntext</span>::<span class="ident">to_text</span>;
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">to_text</span><span class="macro">!</span>(<span class="number">7123</span>),<span class="string">&quot;Seven Thousand,One Hundred,Twenty-Three&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">to_text</span><span class="macro">!</span>(<span class="number">1000</span>),<span class="string">&quot;One Thousand&quot;</span>);
}</pre></div>
<p>Example program with custom formatting</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">extern</span> <span class="kw">crate</span> <span class="ident">ntext</span>;
<span class="kw">use</span> <span class="ident">ntext</span>::{<span class="ident">Formatting</span>,<span class="ident">to_text</span>};
<span class="kw">fn</span> <span class="ident">main</span>() {
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">to_text</span><span class="macro">!</span>(<span class="number">1000</span>, <span class="kw-2">&amp;</span><span class="ident">Formatting</span>::<span class="ident">none</span>().<span class="ident">capitalize</span>()),<span class="string">&quot;OneThousand&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="macro">to_text</span><span class="macro">!</span>(<span class="number">34123</span>, <span class="kw-2">&amp;</span><span class="ident">Formatting</span>::<span class="ident">with_seperator</span>(<span class="string">&quot;#&quot;</span>).<span class="ident">capitalize</span>()),<span class="string">&quot;Thirty#Four#Thousand#One#Hundred#Twenty#Three&quot;</span>);
}</pre></div>
<p>This macro will also return an empty string on input zero<br />
You can also create the Formatting struct manually<br />
Source <a href="https://github.com/uttarayan21/ntext-rs">ntext-rs</a> </p>
</div><h2 id="macros" class="section-header"><a href="#macros">Macros</a></h2>
<table><tr class="module-item"><td><a class="macro" href="macro.to_text.html" title="ntext::to_text macro">to_text</a></td><td class="docblock-short"><p>Macro which supports both seperator and without it</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.Formatting.html" title="ntext::Formatting struct">Formatting</a></td><td class="docblock-short"><p>Set the formatting of the output </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.digit_to_text.html" title="ntext::digit_to_text fn">digit_to_text</a></td><td class="docblock-short"><p>Convert digit to words in a string.</p>
</td></tr><tr class="module-item"><td><a class="fn" href="fn.to_text_fmt.html" title="ntext::to_text_fmt fn">to_text_fmt</a></td><td class="docblock-short"><p>Convert usize to words in a string seperated by a seperator.</p>
</td></tr></table></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../";window.currentCrate = "ntext";</script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>