Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates > by-pkgid > 564935689ab5527f955e5449ded02799 > files > 515

rust-doc-1.19.0-1.mga6.armv7hl.rpm

<!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 `Formatter` struct in crate `collections`.">
    <meta name="keywords" content="rust, rustlang, rust-lang, Formatter">

    <title>collections::fmt::Formatter - Rust</title>

    <link rel="stylesheet" type="text/css" href="../../normalize.css">
    <link rel="stylesheet" type="text/css" href="../../rustdoc.css">
    <link rel="stylesheet" type="text/css" href="../../main.css">
    

    <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico">
    
</head>
<body class="rustdoc struct">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    

    <nav class="sidebar">
        <a href='../../collections/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a>
        <p class='location'>Struct Formatter</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='../index.html'>collections</a>::<wbr><a href='index.html'>fmt</a></p><script>window.sidebarCurrent = {name: 'Formatter', ty: 'struct', relpath: ''};</script><script defer src="sidebar-items.js"></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">
<h1 class='fqn'><span class='in-band'>Struct <a href='../index.html'>collections</a>::<wbr><a href='index.html'>fmt</a>::<wbr><a class="struct" href=''>Formatter</a></span><span class='out-of-band'><span class='since' title='Stable since Rust version 1.0.0'>1.0.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='../../src/core/fmt/mod.rs.html#231-241' title='goto source code'>[src]</a></span></h1>
<pre class='rust struct'>pub struct Formatter&lt;'a&gt; { /* fields omitted */ }</pre><div class='docblock'><p>A struct to represent both where to emit formatting strings to and how they
should be formatted. A mutable version of this is passed to all formatting
traits.</p>
</div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class="struct" href="../../collections/fmt/struct.Formatter.html" title="struct collections::fmt::Formatter">Formatter</a>&lt;'a&gt;</code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../../src/core/fmt/mod.rs.html#975-1444' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.pad_integral' class="method"><span id='pad_integral.v' class='invisible'><code>fn <a href='#method.pad_integral' class='fnname'>pad_integral</a>(<br>&nbsp;&nbsp;&nbsp;&nbsp;&amp;mut self, <br>&nbsp;&nbsp;&nbsp;&nbsp;is_nonnegative: bool, <br>&nbsp;&nbsp;&nbsp;&nbsp;prefix: &amp;str, <br>&nbsp;&nbsp;&nbsp;&nbsp;buf: &amp;str<br>) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Performs the correct padding for an integer which has already been
emitted into a str. The str should <em>not</em> contain the sign for the
integer, that will be added by this method.</p>

<h1 id='arguments' class='section-header'><a href='#arguments'>Arguments</a></h1>
<ul>
<li>is_nonnegative - whether the original integer was either positive or zero.</li>
<li>prefix - if the &#39;#&#39; character (Alternate) is provided, this
is the prefix to put in front of the number.</li>
<li>buf - the byte array that the number has been formatted into</li>
</ul>

<p>This function will correctly account for the flags provided as well as
the minimum width. It will not take precision into account.</p>
</div><h4 id='method.pad' class="method"><span id='pad.v' class='invisible'><code>fn <a href='#method.pad' class='fnname'>pad</a>(&amp;mut self, s: &amp;str) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>This function takes a string slice and emits it to the internal buffer
after applying the relevant formatting flags specified. The flags
recognized for generic strings are:</p>

<ul>
<li>width - the minimum width of what to emit</li>
<li>fill/align - what to emit and where to emit it if the string
           provided needs to be padded</li>
<li>precision - the maximum length to emit, the string is truncated if it
          is longer than this length</li>
</ul>

<p>Notably this function ignores the <code>flag</code> parameters.</p>
</div><h4 id='method.write_str' class="method"><span id='write_str.v' class='invisible'><code>fn <a href='#method.write_str' class='fnname'>write_str</a>(&amp;mut self, data: &amp;str) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Writes some data to the underlying buffer contained within this
formatter.</p>
</div><h4 id='method.write_fmt' class="method"><span id='write_fmt.v' class='invisible'><code>fn <a href='#method.write_fmt' class='fnname'>write_fmt</a>(&amp;mut self, fmt: <a class="struct" href="../../collections/fmt/struct.Arguments.html" title="struct collections::fmt::Arguments">Arguments</a>) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Writes some formatted information into this instance</p>
</div><h4 id='method.flags' class="method"><span id='flags.v' class='invisible'><code>fn <a href='#method.flags' class='fnname'>flags</a>(&amp;self) -&gt; u32</code></span></h4>
<div class='docblock'><p>Flags for formatting (packed version of rt::Flag)</p>
</div><h4 id='method.fill' class="method"><span id='fill.v' class='invisible'><code>fn <a href='#method.fill' class='fnname'>fill</a>(&amp;self) -&gt; char</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Character used as &#39;fill&#39; whenever there is alignment</p>
</div><h4 id='method.align' class="method"><span id='align.v' class='invisible'><code>fn <a href='#method.align' class='fnname'>align</a>(&amp;self) -&gt; <a class="enum" href="../../core/fmt/enum.Alignment.html" title="enum core::fmt::Alignment">Alignment</a></code></span></h4>
<div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API.  (<code>fmt_flags_align </code><a href="https://github.com/rust-lang/rust/issues/27726">#27726</a>)</summary><p>method was just created</p>
</details></div></div><div class='docblock'><p>Flag indicating what form of alignment was requested</p>
</div><h4 id='method.width' class="method"><span id='width.v' class='invisible'><code>fn <a href='#method.width' class='fnname'>width</a>(&amp;self) -&gt; <a class="enum" href="../../core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;usize&gt;</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Optionally specified integer width that the output should be</p>
</div><h4 id='method.precision' class="method"><span id='precision.v' class='invisible'><code>fn <a href='#method.precision' class='fnname'>precision</a>(&amp;self) -&gt; <a class="enum" href="../../core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;usize&gt;</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Optionally specified precision for numeric types</p>
</div><h4 id='method.sign_plus' class="method"><span id='sign_plus.v' class='invisible'><code>fn <a href='#method.sign_plus' class='fnname'>sign_plus</a>(&amp;self) -&gt; bool</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Determines if the <code>+</code> flag was specified.</p>
</div><h4 id='method.sign_minus' class="method"><span id='sign_minus.v' class='invisible'><code>fn <a href='#method.sign_minus' class='fnname'>sign_minus</a>(&amp;self) -&gt; bool</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Determines if the <code>-</code> flag was specified.</p>
</div><h4 id='method.alternate' class="method"><span id='alternate.v' class='invisible'><code>fn <a href='#method.alternate' class='fnname'>alternate</a>(&amp;self) -&gt; bool</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Determines if the <code>#</code> flag was specified.</p>
</div><h4 id='method.sign_aware_zero_pad' class="method"><span id='sign_aware_zero_pad.v' class='invisible'><code>fn <a href='#method.sign_aware_zero_pad' class='fnname'>sign_aware_zero_pad</a>(&amp;self) -&gt; bool</code><div class='since' title='Stable since Rust version 1.5.0'>1.5.0</div></span></h4>
<div class='docblock'><p>Determines if the <code>0</code> flag was specified.</p>
</div><h4 id='method.debug_struct' class="method"><span id='debug_struct.v' class='invisible'><code>fn <a href='#method.debug_struct' class='fnname'>debug_struct</a>(&amp;'b mut self, name: &amp;str) -&gt; <a class="struct" href="../../collections/fmt/struct.DebugStruct.html" title="struct collections::fmt::DebugStruct">DebugStruct</a>&lt;'b, 'a&gt;</code><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div></span></h4>
<div class='docblock'><p>Creates a <code>DebugStruct</code> builder designed to assist with creation of
<code>fmt::Debug</code> implementations for structs.</p>

<h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;

<span class="kw">struct</span> <span class="ident">Foo</span> {
    <span class="ident">bar</span>: <span class="ident">i32</span>,
    <span class="ident">baz</span>: <span class="ident">String</span>,
}

<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">Foo</span> {
    <span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">fmt</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
        <span class="ident">fmt</span>.<span class="ident">debug_struct</span>(<span class="string">&quot;Foo&quot;</span>)
            .<span class="ident">field</span>(<span class="string">&quot;bar&quot;</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">bar</span>)
            .<span class="ident">field</span>(<span class="string">&quot;baz&quot;</span>, <span class="kw-2">&amp;</span><span class="self">self</span>.<span class="ident">baz</span>)
            .<span class="ident">finish</span>()
    }
}

<span class="comment">// prints &quot;Foo { bar: 10, baz: &quot;Hello World&quot; }&quot;</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">Foo</span> { <span class="ident">bar</span>: <span class="number">10</span>, <span class="ident">baz</span>: <span class="string">&quot;Hello World&quot;</span>.<span class="ident">to_string</span>() });<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afmt%3B%0A%0Astruct%20Foo%20%7B%0A%20%20%20%20bar%3A%20i32%2C%0A%20%20%20%20baz%3A%20String%2C%0A%7D%0A%0Aimpl%20fmt%3A%3ADebug%20for%20Foo%20%7B%0A%20%20%20%20fn%20fmt(%26self%2C%20fmt%3A%20%26mut%20fmt%3A%3AFormatter)%20-%3E%20fmt%3A%3AResult%20%7B%0A%20%20%20%20%20%20%20%20fmt.debug_struct(%22Foo%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20.field(%22bar%22%2C%20%26self.bar)%0A%20%20%20%20%20%20%20%20%20%20%20%20.field(%22baz%22%2C%20%26self.baz)%0A%20%20%20%20%20%20%20%20%20%20%20%20.finish()%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20prints%20%22Foo%20%7B%20bar%3A%2010%2C%20baz%3A%20%22Hello%20World%22%20%7D%22%0Aprintln!(%22%7B%3A%3F%7D%22%2C%20Foo%20%7B%20bar%3A%2010%2C%20baz%3A%20%22Hello%20World%22.to_string()%20%7D)%3B%0A%7D">Run</a></pre>
</div><h4 id='method.debug_tuple' class="method"><span id='debug_tuple.v' class='invisible'><code>fn <a href='#method.debug_tuple' class='fnname'>debug_tuple</a>(&amp;'b mut self, name: &amp;str) -&gt; <a class="struct" href="../../collections/fmt/struct.DebugTuple.html" title="struct collections::fmt::DebugTuple">DebugTuple</a>&lt;'b, 'a&gt;</code><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div></span></h4>
<div class='docblock'><p>Creates a <code>DebugTuple</code> builder designed to assist with creation of
<code>fmt::Debug</code> implementations for tuple structs.</p>

<h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;

<span class="kw">struct</span> <span class="ident">Foo</span>(<span class="ident">i32</span>, <span class="ident">String</span>);

<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">Foo</span> {
    <span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">fmt</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
        <span class="ident">fmt</span>.<span class="ident">debug_tuple</span>(<span class="string">&quot;Foo&quot;</span>)
            .<span class="ident">field</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">0</span>)
            .<span class="ident">field</span>(<span class="kw-2">&amp;</span><span class="self">self</span>.<span class="number">1</span>)
            .<span class="ident">finish</span>()
    }
}

<span class="comment">// prints &quot;Foo(10, &quot;Hello World&quot;)&quot;</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">Foo</span>(<span class="number">10</span>, <span class="string">&quot;Hello World&quot;</span>.<span class="ident">to_string</span>()));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afmt%3B%0A%0Astruct%20Foo(i32%2C%20String)%3B%0A%0Aimpl%20fmt%3A%3ADebug%20for%20Foo%20%7B%0A%20%20%20%20fn%20fmt(%26self%2C%20fmt%3A%20%26mut%20fmt%3A%3AFormatter)%20-%3E%20fmt%3A%3AResult%20%7B%0A%20%20%20%20%20%20%20%20fmt.debug_tuple(%22Foo%22)%0A%20%20%20%20%20%20%20%20%20%20%20%20.field(%26self.0)%0A%20%20%20%20%20%20%20%20%20%20%20%20.field(%26self.1)%0A%20%20%20%20%20%20%20%20%20%20%20%20.finish()%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20prints%20%22Foo(10%2C%20%22Hello%20World%22)%22%0Aprintln!(%22%7B%3A%3F%7D%22%2C%20Foo(10%2C%20%22Hello%20World%22.to_string()))%3B%0A%7D">Run</a></pre>
</div><h4 id='method.debug_list' class="method"><span id='debug_list.v' class='invisible'><code>fn <a href='#method.debug_list' class='fnname'>debug_list</a>(&amp;'b mut self) -&gt; <a class="struct" href="../../collections/fmt/struct.DebugList.html" title="struct collections::fmt::DebugList">DebugList</a>&lt;'b, 'a&gt;</code><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div></span></h4>
<div class='docblock'><p>Creates a <code>DebugList</code> builder designed to assist with creation of
<code>fmt::Debug</code> implementations for list-like structures.</p>

<h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;

<span class="kw">struct</span> <span class="ident">Foo</span>(<span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>);

<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">Foo</span> {
    <span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">fmt</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
        <span class="ident">fmt</span>.<span class="ident">debug_list</span>().<span class="ident">entries</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">iter</span>()).<span class="ident">finish</span>()
    }
}

<span class="comment">// prints &quot;[10, 11]&quot;</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">Foo</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">11</span>]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afmt%3B%0A%0Astruct%20Foo(Vec%3Ci32%3E)%3B%0A%0Aimpl%20fmt%3A%3ADebug%20for%20Foo%20%7B%0A%20%20%20%20fn%20fmt(%26self%2C%20fmt%3A%20%26mut%20fmt%3A%3AFormatter)%20-%3E%20fmt%3A%3AResult%20%7B%0A%20%20%20%20%20%20%20%20fmt.debug_list().entries(self.0.iter()).finish()%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20prints%20%22%5B10%2C%2011%5D%22%0Aprintln!(%22%7B%3A%3F%7D%22%2C%20Foo(vec!%5B10%2C%2011%5D))%3B%0A%7D">Run</a></pre>
</div><h4 id='method.debug_set' class="method"><span id='debug_set.v' class='invisible'><code>fn <a href='#method.debug_set' class='fnname'>debug_set</a>(&amp;'b mut self) -&gt; <a class="struct" href="../../collections/fmt/struct.DebugSet.html" title="struct collections::fmt::DebugSet">DebugSet</a>&lt;'b, 'a&gt;</code><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div></span></h4>
<div class='docblock'><p>Creates a <code>DebugSet</code> builder designed to assist with creation of
<code>fmt::Debug</code> implementations for set-like structures.</p>

<h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;

<span class="kw">struct</span> <span class="ident">Foo</span>(<span class="ident">Vec</span><span class="op">&lt;</span><span class="ident">i32</span><span class="op">&gt;</span>);

<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">Foo</span> {
    <span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">fmt</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
        <span class="ident">fmt</span>.<span class="ident">debug_set</span>().<span class="ident">entries</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">iter</span>()).<span class="ident">finish</span>()
    }
}

<span class="comment">// prints &quot;{10, 11}&quot;</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">Foo</span>(<span class="macro">vec</span><span class="macro">!</span>[<span class="number">10</span>, <span class="number">11</span>]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afmt%3B%0A%0Astruct%20Foo(Vec%3Ci32%3E)%3B%0A%0Aimpl%20fmt%3A%3ADebug%20for%20Foo%20%7B%0A%20%20%20%20fn%20fmt(%26self%2C%20fmt%3A%20%26mut%20fmt%3A%3AFormatter)%20-%3E%20fmt%3A%3AResult%20%7B%0A%20%20%20%20%20%20%20%20fmt.debug_set().entries(self.0.iter()).finish()%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20prints%20%22%7B10%2C%2011%7D%22%0Aprintln!(%22%7B%3A%3F%7D%22%2C%20Foo(vec!%5B10%2C%2011%5D))%3B%0A%7D">Run</a></pre>
</div><h4 id='method.debug_map' class="method"><span id='debug_map.v' class='invisible'><code>fn <a href='#method.debug_map' class='fnname'>debug_map</a>(&amp;'b mut self) -&gt; <a class="struct" href="../../collections/fmt/struct.DebugMap.html" title="struct collections::fmt::DebugMap">DebugMap</a>&lt;'b, 'a&gt;</code><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div></span></h4>
<div class='docblock'><p>Creates a <code>DebugMap</code> builder designed to assist with creation of
<code>fmt::Debug</code> implementations for map-like structures.</p>

<h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">std</span>::<span class="ident">fmt</span>;

<span class="kw">struct</span> <span class="ident">Foo</span>(<span class="ident">Vec</span><span class="op">&lt;</span>(<span class="ident">String</span>, <span class="ident">i32</span>)<span class="op">&gt;</span>);

<span class="kw">impl</span> <span class="ident">fmt</span>::<span class="ident">Debug</span> <span class="kw">for</span> <span class="ident">Foo</span> {
    <span class="kw">fn</span> <span class="ident">fmt</span>(<span class="kw-2">&amp;</span><span class="self">self</span>, <span class="ident">fmt</span>: <span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="ident">fmt</span>::<span class="ident">Formatter</span>) <span class="op">-&gt;</span> <span class="ident">fmt</span>::<span class="prelude-ty">Result</span> {
        <span class="ident">fmt</span>.<span class="ident">debug_map</span>().<span class="ident">entries</span>(<span class="self">self</span>.<span class="number">0</span>.<span class="ident">iter</span>().<span class="ident">map</span>(<span class="op">|</span><span class="kw-2">&amp;</span>(<span class="kw-2">ref</span> <span class="ident">k</span>, <span class="kw-2">ref</span> <span class="ident">v</span>)<span class="op">|</span> (<span class="ident">k</span>, <span class="ident">v</span>))).<span class="ident">finish</span>()
    }
}

<span class="comment">// prints &quot;{&quot;A&quot;: 10, &quot;B&quot;: 11}&quot;</span>
<span class="macro">println</span><span class="macro">!</span>(<span class="string">&quot;{:?}&quot;</span>, <span class="ident">Foo</span>(<span class="macro">vec</span><span class="macro">!</span>[(<span class="string">&quot;A&quot;</span>.<span class="ident">to_string</span>(), <span class="number">10</span>), (<span class="string">&quot;B&quot;</span>.<span class="ident">to_string</span>(), <span class="number">11</span>)]));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Afmt%3B%0A%0Astruct%20Foo(Vec%3C(String%2C%20i32)%3E)%3B%0A%0Aimpl%20fmt%3A%3ADebug%20for%20Foo%20%7B%0A%20%20%20%20fn%20fmt(%26self%2C%20fmt%3A%20%26mut%20fmt%3A%3AFormatter)%20-%3E%20fmt%3A%3AResult%20%7B%0A%20%20%20%20%20%20%20%20fmt.debug_map().entries(self.0.iter().map(%7C%26(ref%20k%2C%20ref%20v)%7C%20(k%2C%20v))).finish()%0A%20%20%20%20%7D%0A%7D%0A%0A%2F%2F%20prints%20%22%7B%22A%22%3A%2010%2C%20%22B%22%3A%2011%7D%22%0Aprintln!(%22%7B%3A%3F%7D%22%2C%20Foo(vec!%5B(%22A%22.to_string()%2C%2010)%2C%20(%22B%22.to_string()%2C%2011)%5D))%3B%0A%7D">Run</a></pre>
</div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl&lt;'a&gt; <a class="trait" href="../../collections/fmt/trait.Write.html" title="trait collections::fmt::Write">Write</a> for <a class="struct" href="../../collections/fmt/struct.Formatter.html" title="struct collections::fmt::Formatter">Formatter</a>&lt;'a&gt;</code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.2.0'>1.2.0</div><a class='srclink' href='../../src/core/fmt/mod.rs.html#1447-1459' title='goto source code'>[src]</a></span></h3>
<div class='impl-items'><h4 id='method.write_str-1' class="method"><span id='write_str.v-1' class='invisible'><code>fn <a href='../../collections/fmt/trait.Write.html#tymethod.write_str' class='fnname'>write_str</a>(&amp;mut self, s: &amp;str) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Writes a slice of bytes into this writer, returning whether the write succeeded. <a href="../../collections/fmt/trait.Write.html#tymethod.write_str">Read more</a></p>
</div><h4 id='method.write_char' class="method"><span id='write_char.v' class='invisible'><code>fn <a href='../../collections/fmt/trait.Write.html#method.write_char' class='fnname'>write_char</a>(&amp;mut self, c: char) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Writes a [<code>char</code>] into this writer, returning whether the write succeeded. <a href="../../collections/fmt/trait.Write.html#method.write_char">Read more</a></p>
</div><h4 id='method.write_fmt-1' class="method"><span id='write_fmt.v-1' class='invisible'><code>fn <a href='../../collections/fmt/trait.Write.html#method.write_fmt' class='fnname'>write_fmt</a>(&amp;mut self, args: <a class="struct" href="../../collections/fmt/struct.Arguments.html" title="struct collections::fmt::Arguments">Arguments</a>) -&gt; <a class="enum" href="../../core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;(), <a class="struct" href="../../collections/fmt/struct.Error.html" title="struct collections::fmt::Error">Error</a>&gt;</code></span></h4>
<div class='docblock'><p>Glue for usage of the [<code>write!</code>] macro with implementors of this trait. <a href="../../collections/fmt/trait.Write.html#method.write_fmt">Read more</a></p>
</div></div></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 = "collections";
    </script>
    <script src="../../main.js"></script>
    <script defer src="../../search-index.js"></script>
</body>
</html>