You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
Trac3r-rust/doc/typenum/index.html

60 lines
13 KiB

5 years ago
<!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 `typenum` crate."><meta name="keywords" content="rust, rustlang, rust-lang, typenum"><title>typenum - 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="../dark.css"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="shortcut icon" href="../favicon.ico"><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='../typenum/index.html'><div class='logo-container'><img src='../rust-logo.png' alt='logo'></div></a><p class='location'>Crate typenum</p><div class="sidebar-elems"><a id='all-types' href='all.html'><p>See all typenum'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="#macros">Macros</a></li><li><a href="#structs">Structs</a></li></ul></div><p class='location'></p><script>window.sidebarCurrent = {name: 'typenum', ty: 'mod', relpath: '../'};</script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form js-only"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><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/typenum/lib.rs.html#1-135' title='goto source code'>[src]</a></span><span class='in-band'>Crate <a class="mod" href=''>typenum</a></span></h1><div class='docblock'><p>This crate provides type-level numbers evaluated at compile time. It depends only on libcore.</p>
<p>The traits defined or used in this crate are used in a typical manner. They can be divided into
two categories: <strong>marker traits</strong> and <strong>type operators</strong>.</p>
<p>Many of the marker traits have functions defined, but they all do essentially the same thing:
convert a type into its runtime counterpart, and are really just there for debugging. For
example,</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">typenum</span>::{<span class="ident">N4</span>, <span class="ident">Integer</span>};
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">N4</span>::<span class="ident">to_i32</span>(), <span class="op">-</span><span class="number">4</span>);</pre></div>
<p><strong>Type operators</strong> are traits that behave as functions at the type level. These are the meat of
this library. Where possible, traits defined in libcore have been used, but their attached
functions have not been implemented.</p>
<p>For example, the <code>Add</code> trait is implemented for both unsigned and signed integers, but the
<code>add</code> function is not. As there are never any objects of the types defined here, it wouldn't
make sense to implement it. What is important is its associated type <code>Output</code>, which is where
the addition happens.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">ops</span>::<span class="ident">Add</span>;
<span class="kw">use</span> <span class="ident">typenum</span>::{<span class="ident">Integer</span>, <span class="ident">P3</span>, <span class="ident">P4</span>};
<span class="kw">type</span> <span class="ident">X</span> <span class="op">=</span> <span class="op">&lt;</span><span class="ident">P3</span> <span class="kw">as</span> <span class="ident">Add</span><span class="op">&lt;</span><span class="ident">P4</span><span class="op">&gt;</span><span class="op">&gt;</span>::<span class="ident">Output</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">&lt;</span><span class="ident">X</span> <span class="kw">as</span> <span class="ident">Integer</span><span class="op">&gt;</span>::<span class="ident">to_i32</span>(), <span class="number">7</span>);</pre></div>
<p>In addition, helper aliases are defined for type operators. For example, the above snippet
could be replaced with</p>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">typenum</span>::{<span class="ident">Sum</span>, <span class="ident">Integer</span>, <span class="ident">P3</span>, <span class="ident">P4</span>};
<span class="kw">type</span> <span class="ident">X</span> <span class="op">=</span> <span class="ident">Sum</span><span class="op">&lt;</span><span class="ident">P3</span>, <span class="ident">P4</span><span class="op">&gt;</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="op">&lt;</span><span class="ident">X</span> <span class="kw">as</span> <span class="ident">Integer</span><span class="op">&gt;</span>::<span class="ident">to_i32</span>(), <span class="number">7</span>);</pre></div>
<p>Documented in each module is the full list of type operators implemented.</p>
</div><h2 id='reexports' class='section-header'><a href="#reexports">Re-exports</a></h2>
<table><tr><td><code>pub use <a class="mod" href="../typenum/consts/index.html" title="mod typenum::consts">consts</a>::*;</code></td></tr><tr><td><code>pub use <a class="mod" href="../typenum/marker_traits/index.html" title="mod typenum::marker_traits">marker_traits</a>::*;</code></td></tr><tr><td><code>pub use <a class="mod" href="../typenum/type_operators/index.html" title="mod typenum::type_operators">type_operators</a>::*;</code></td></tr><tr><td><code>pub use <a class="mod" href="../typenum/operator_aliases/index.html" title="mod typenum::operator_aliases">operator_aliases</a>::*;</code></td></tr><tr><td><code>pub use uint::<a class="struct" href="../typenum/uint/struct.UInt.html" title="struct typenum::uint::UInt">UInt</a>;</code></td></tr><tr><td><code>pub use uint::<a class="struct" href="../typenum/uint/struct.UTerm.html" title="struct typenum::uint::UTerm">UTerm</a>;</code></td></tr><tr><td><code>pub use int::<a class="struct" href="../typenum/int/struct.NInt.html" title="struct typenum::int::NInt">NInt</a>;</code></td></tr><tr><td><code>pub use int::<a class="struct" href="../typenum/int/struct.PInt.html" title="struct typenum::int::PInt">PInt</a>;</code></td></tr><tr><td><code>pub use array::<a class="struct" href="../typenum/array/struct.ATerm.html" title="struct typenum::array::ATerm">ATerm</a>;</code></td></tr><tr><td><code>pub use array::<a class="struct" href="../typenum/array/struct.TArr.html" title="struct typenum::array::TArr">TArr</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="array/index.html" title='typenum::array mod'>array</a></td><td class='docblock-short'><p>A type-level array of type-level numbers.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="bit/index.html" title='typenum::bit mod'>bit</a></td><td class='docblock-short'><p>Type-level bits.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="consts/index.html" title='typenum::consts mod'>consts</a></td><td class='docblock-short'><p>Type aliases for many constants.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="int/index.html" title='typenum::int mod'>int</a></td><td class='docblock-short'><p>Type-level signed integers.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="marker_traits/index.html" title='typenum::marker_traits mod'>marker_traits</a></td><td class='docblock-short'><p>All of the <strong>marker traits</strong> used in typenum.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="operator_aliases/index.html" title='typenum::operator_aliases mod'>operator_aliases</a></td><td class='docblock-short'><p>Aliases for the type operators used in this crate.
Their purpose is to increase the ergonomics of performing operations on the types defined
here. For even more ergonomics, consider using the <code>op!</code> macro instead.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="type_operators/index.html" title='typenum::type_operators mod'>type_operators</a></td><td class='docblock-short'><p>Useful <strong>type operators</strong> that are not defined in <code>core::ops</code>.</p>
</td></tr><tr class='module-item'><td><a class="mod" href="uint/index.html" title='typenum::uint mod'>uint</a></td><td class='docblock-short'><p>Type-level unsigned integers.</p>
</td></tr></table><h2 id='macros' class='section-header'><a href="#macros">Macros</a></h2>
<table><tr class='module-item'><td><a class="macro" href="macro.assert_type.html" title='typenum::assert_type macro'>assert_type</a></td><td class='docblock-short'><p>Asserts that a type is <code>True</code>, aka <code>B1</code>.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.assert_type_eq.html" title='typenum::assert_type_eq macro'>assert_type_eq</a></td><td class='docblock-short'><p>Asserts that two types are the same.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.cmp.html" title='typenum::cmp macro'>cmp</a></td><td class='docblock-short'><span class="stab deprecated">Deprecated</span><p>A convenience macro for comparing type numbers. Use <code>op!</code> instead.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.op.html" title='typenum::op macro'>op</a></td><td class='docblock-short'><p>Convenient type operations.</p>
</td></tr><tr class='module-item'><td><a class="macro" href="macro.tarr.html" title='typenum::tarr macro'>tarr</a></td><td class='docblock-short'><p>Create a new type-level arrray. Only usable on Rust 1.13.0 or newer.</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.Equal.html" title='typenum::Equal struct'>Equal</a></td><td class='docblock-short'><p>A potential output from <code>Cmp</code>, this is the type equivalent to the enum variant
<code>core::cmp::Ordering::Equal</code>.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Greater.html" title='typenum::Greater struct'>Greater</a></td><td class='docblock-short'><p>A potential output from <code>Cmp</code>, this is the type equivalent to the enum variant
<code>core::cmp::Ordering::Greater</code>.</p>
</td></tr><tr class='module-item'><td><a class="struct" href="struct.Less.html" title='typenum::Less struct'>Less</a></td><td class='docblock-short'><p>A potential output from <code>Cmp</code>, this is the type equivalent to the enum variant
<code>core::cmp::Ordering::Less</code>.</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><kbd>?</kbd></dt><dd>Show this help dialog</dd><dt><kbd>S</kbd></dt><dd>Focus the search field</dd><dt><kbd></kbd></dt><dd>Move up in search results</dd><dt><kbd></kbd></dt><dd>Move down in search results</dd><dt><kbd></kbd></dt><dd>Switch tab</dd><dt><kbd>&#9166;</kbd></dt><dd>Go to active search result</dd><dt><kbd>+</kbd></dt><dd>Expand all sections</dd><dt><kbd>-</kbd></dt><dd>Collapse 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><p>Search multiple things at once by splitting your query with comma (e.g., <code>str,u8</code> or <code>String,struct:Vec,test</code>)</p></div></div></aside><script>window.rootPath = "../";window.currentCrate = "typenum";</script><script src="../aliases.js"></script><script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>