Sophie

Sophie

distrib > Mageia > 6 > x86_64 > by-pkgid > cb677c027f0cc5c56853dd08d65bfb88 > files > 407

rust-doc-1.27.1-1.1.mga6.x86_64.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">
    <title>Associated Types</title>

    <link rel="stylesheet" type="text/css" href="../rust.css">

    <link rel="shortcut icon" href="https://www.rust-lang.org/favicon.ico">


</head>
<body class="rustdoc">
    <!--[if lte IE 8]>
    <div class="warning">
        This old browser is unsupported and will most likely display funky
        things.
    </div>
    <![endif]-->

    <div id="versioninfo">
  <img src="https://www.rust-lang.org/logos/rust-logo-32x32-blk.png" width="32" height="32" alt="Rust logo"><br>
  <span class="white-sticker"><a href="https://www.rust-lang.org">Rust</a> 1.27.1</span><br>
  <a href="https://github.com/rust-lang/rust/commit/"
    class="hash white-sticker"></a>
</div>


    <h1 class="title">Associated Types</h1>
    <p><small>There is a new edition of the book and this is an old link.</small></p>
<blockquote>
<p>Associated types are a way of associating a type placeholder with a trait such that the trait method definitions can use these placeholder types in their signatures.</p>
</blockquote>

<pre class="rust rust-example-rendered">
<span class="kw">pub</span> <span class="kw">trait</span> <span class="ident">Iterator</span> {
    <span class="kw">type</span> <span class="ident">Item</span>;
    <span class="kw">fn</span> <span class="ident">next</span>(<span class="kw-2">&amp;</span><span class="kw-2">mut</span> <span class="self">self</span>) <span class="op">-&gt;</span> <span class="prelude-ty">Option</span><span class="op">&lt;</span><span class="self">Self</span>::<span class="ident">Item</span><span class="op">&gt;</span>;
}<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Ballow(unused)%5D%0Afn%20main()%20%7B%0Apub%20trait%20Iterator%20%7B%0A%20%20%20%20type%20Item%3B%0A%20%20%20%20fn%20next(%26mut%20self)%20-%3E%20Option%3CSelf%3A%3AItem%3E%3B%0A%7D%0A%7D">Run</a></pre>
<hr />
<p>Here are the relevant sections in the new and old books:</p>
<ul>
<li><strong><a href="second-edition/ch19-03-advanced-traits.html#associated-types-specify-placeholder-types-in-trait-definitions">In the second edition: Ch 19.03 — Advanced Traits</a></strong></li>
<li><small><a href="first-edition/associated-types.html">In the first edition: Ch 3.30 — Associated Types</a></small></li>
</ul>

    <footer><p>
Copyright &copy; 2011 The Rust Project Developers. Licensed under the
<a href="http://www.apache.org/licenses/LICENSE-2.0">Apache License, Version 2.0</a>
or the <a href="https://opensource.org/licenses/MIT">MIT license</a>, at your option.
</p><p>
This file may not be copied, modified, or distributed except according to those terms.
</p></footer>


</body>
</html>