Files
mercator_service/nom/lib/std/hash/trait.BuildHasher.html

38 lines
11 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 `BuildHasher` trait in crate `nom`."><meta name="keywords" content="rust, rustlang, rust-lang, BuildHasher"><title>nom::lib::std::hash::BuildHasher - 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 trait"><!--[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='../../../../nom/index.html'><div class='logo-container'><img src='../../../../rust-logo.png' alt='logo'></div></a><p class='location'>Trait BuildHasher</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Hasher">Hasher</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.build_hasher">build_hasher</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class='location'><a href='../../../index.html'>nom</a>::<wbr><a href='../../index.html'>lib</a>::<wbr><a href='../index.html'>std</a>::<wbr><a href='index.html'>hash</a></p><script>window.sidebarCurrent = {name: 'BuildHasher', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></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"><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><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 class='since' title='Stable since Rust version 1.7.0'>1.7.0</span><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='https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#442-465' title='goto source code'>[src]</a></span><span class='in-band'>Trait <a href='../../../index.html'>nom</a>::<wbr><a href='../../index.html'>lib</a>::<wbr><a href='../index.html'>std</a>::<wbr><a href='index.html'>hash</a>::<wbr><a class="trait" href=''>BuildHasher</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class='rust trait'>pub trait BuildHasher {
type <a href='#associatedtype.Hasher' class="type">Hasher</a>: <a class="trait" href="../../../../nom/lib/std/hash/trait.Hasher.html" title="trait nom::lib::std::hash::Hasher">Hasher</a>;
fn <a href='#tymethod.build_hasher' class='fnname'>build_hasher</a>(&amp;self) -&gt; Self::<a class="type" href="../../../../nom/lib/std/hash/trait.BuildHasher.html#associatedtype.Hasher" title="type nom::lib::std::hash::BuildHasher::Hasher">Hasher</a>;
}</pre></div><div class='docblock'><p>A trait for creating instances of <a href="trait.Hasher.html"><code>Hasher</code></a>.</p>
<p>A <code>BuildHasher</code> is typically used (e.g., by <a href="../../std/collections/struct.HashMap.html"><code>HashMap</code></a>) to create
<a href="trait.Hasher.html"><code>Hasher</code></a>s for each key such that they are hashed independently of one
another, since <a href="trait.Hasher.html"><code>Hasher</code></a>s contain state.</p>
<p>For each instance of <code>BuildHasher</code>, the <a href="trait.Hasher.html"><code>Hasher</code></a>s created by
<a href="#tymethod.build_hasher"><code>build_hasher</code></a> should be identical. That is, if the same stream of bytes
is fed into each hasher, the same output will also be generated.</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">hash_map</span>::<span class="ident">RandomState</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">hash</span>::{<span class="ident">BuildHasher</span>, <span class="ident">Hasher</span>};
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">RandomState</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">hasher_1</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">build_hasher</span>();
<span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">hasher_2</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">build_hasher</span>();
<span class="ident">hasher_1</span>.<span class="ident">write_u32</span>(<span class="number">8128</span>);
<span class="ident">hasher_2</span>.<span class="ident">write_u32</span>(<span class="number">8128</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">hasher_1</span>.<span class="ident">finish</span>(), <span class="ident">hasher_2</span>.<span class="ident">finish</span>());</pre></div>
</div>
<h2 id='associated-types' class='small-section-header'>Associated Types<a href='#associated-types' class='anchor'></a></h2><div class='methods'><h3 id='associatedtype.Hasher' class='method'><code id='Hasher.t'>type <a href='#associatedtype.Hasher' class="type">Hasher</a>: <a class="trait" href="../../../../nom/lib/std/hash/trait.Hasher.html" title="trait nom::lib::std::hash::Hasher">Hasher</a></code></h3><div class='docblock'><p>Type of the hasher that will be created.</p>
</div></div><span class='loading-content'>Loading content...</span>
<h2 id='required-methods' class='small-section-header'>Required methods<a href='#required-methods' class='anchor'></a></h2><div class='methods'><h3 id='tymethod.build_hasher' class='method'><code id='build_hasher.v'>fn <a href='#tymethod.build_hasher' class='fnname'>build_hasher</a>(&amp;self) -&gt; Self::<a class="type" href="../../../../nom/lib/std/hash/trait.BuildHasher.html#associatedtype.Hasher" title="type nom::lib::std::hash::BuildHasher::Hasher">Hasher</a></code></h3><div class='docblock'><p>Creates a new hasher.</p>
<p>Each call to <code>build_hasher</code> on the same instance should produce identical
<a href="trait.Hasher.html"><code>Hasher</code></a>s.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">collections</span>::<span class="ident">hash_map</span>::<span class="ident">RandomState</span>;
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">hash</span>::<span class="ident">BuildHasher</span>;
<span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">RandomState</span>::<span class="ident">new</span>();
<span class="kw">let</span> <span class="ident">new_s</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">build_hasher</span>();</pre></div>
</div></div><span class='loading-content'>Loading content...</span>
<h2 id='implementors' class='small-section-header'>Implementors<a href='#implementors' class='anchor'></a></h2><div class='item-list' id='implementors-list'><h3 id='impl-BuildHasher' class='impl'><code class='in-band'>impl BuildHasher for <a class="struct" href="../../../../nom/lib/std/collections/hash_map/struct.RandomState.html" title="struct nom::lib::std::collections::hash_map::RandomState">RandomState</a></code><a href='#impl-BuildHasher' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/collections/hash/map.rs.html#2470-2477' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Hasher-1' class="type"><code id='Hasher.t-1'>type <a href='#associatedtype.Hasher-1' class="type">Hasher</a> = <a class="struct" href="../../../../nom/lib/std/collections/hash_map/struct.DefaultHasher.html" title="struct nom::lib::std::collections::hash_map::DefaultHasher">DefaultHasher</a></code></h4><h4 id='method.build_hasher' class="method hidden"><code id='build_hasher.v-1'>fn <a href='#method.build_hasher' class='fnname'>build_hasher</a>(&amp;self) -&gt; <a class="struct" href="../../../../nom/lib/std/collections/hash_map/struct.DefaultHasher.html" title="struct nom::lib::std::collections::hash_map::DefaultHasher">DefaultHasher</a></code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/std/collections/hash/map.rs.html#2474-2476' title='goto source code'>[src]</a></h4></div><h3 id='impl-BuildHasher-1' class='impl'><code class='in-band'>impl&lt;H&gt; BuildHasher for <a class="struct" href="../../../../nom/lib/std/hash/struct.BuildHasherDefault.html" title="struct nom::lib::std::hash::BuildHasherDefault">BuildHasherDefault</a>&lt;H&gt; <span class="where fmt-newline">where<br>&nbsp;&nbsp;&nbsp;&nbsp;H: <a class="trait" href="../../../../nom/lib/std/prelude/v1/v1/trait.Default.html" title="trait nom::lib::std::prelude::v1::v1::Default">Default</a> + <a class="trait" href="../../../../nom/lib/std/hash/trait.Hasher.html" title="trait nom::lib::std::hash::Hasher">Hasher</a>,&nbsp;</span></code><a href='#impl-BuildHasher-1' class='anchor'></a><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#526-532' title='goto source code'>[src]</a></h3><div class='impl-items'><h4 id='associatedtype.Hasher-2' class="type"><code id='Hasher.t-2'>type <a href='#associatedtype.Hasher-2' class="type">Hasher</a> = H</code></h4><h4 id='method.build_hasher-1' class="method hidden"><code id='build_hasher.v-2'>fn <a href='#method.build_hasher-1' class='fnname'>build_hasher</a>(&amp;self) -&gt; H</code><a class='srclink' href='https://doc.rust-lang.org/nightly/src/core/hash/mod.rs.html#529-531' title='goto source code'>[src]</a></h4></div></div><span class='loading-content'>Loading content...</span><script type="text/javascript" src="../../../../implementors/core/hash/trait.BuildHasher.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><script>window.rootPath = "../../../../";window.currentCrate = "nom";</script><script src="../../../../aliases.js"></script><script src="../../../../main.js"></script><script defer src="../../../../search-index.js"></script></body></html>