<?xml version="1.0" encoding="UTF-8"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
    <title>Rares Asaftei - rust</title>
    <subtitle>Rares Asaftei&#39;s corner of the web: blog posts about my projects, links, and CV.</subtitle>
    <link rel="self" type="application/atom+xml" href="https://asaft.dev/tags/rust/atom.xml"/>
    <link rel="alternate" type="text/html" href="https://asaft.dev"/>
    <generator uri="https://www.getzola.org/">Zola</generator>
    <updated>2026-11-26T00:00:00+00:00</updated>
    <id>https://asaft.dev/tags/rust/atom.xml</id>
    <entry xml:lang="en">
        <title>The &quot;!&quot; type is officially stable</title>
        <published>2026-11-26T00:00:00+00:00</published>
        <updated>2026-11-26T00:00:00+00:00</updated>
        
        <author>
          <name>Rares Asaftei</name>
        </author>
        
        <link rel="alternate" type="text/html" href="https://asaft.dev/blog/never-type-stable/"/>
        <id>https://asaft.dev/blog/never-type-stable/</id>
        
        <content type="html" xml:base="https://asaft.dev/blog/never-type-stable/">&lt;p&gt;The &lt;code&gt;never&lt;/code&gt; type, also referred to as &lt;code&gt;!&lt;/code&gt;, has existed in the compiler for over a decade.&lt;/p&gt;
&lt;p&gt;It spent years stuck behind &lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&quot;&gt;nightly&lt;/a&gt;: you could observe it in error messages and
even write &lt;code&gt;fn foo() -&amp;gt; !&lt;/code&gt;, but you could not name it anywhere else.&lt;/p&gt;
&lt;p&gt;After 10
years, Rust 1.100.0 finally made it stable.&lt;/p&gt;
&lt;p&gt;If you want to play with it:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;shellsession&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;$&lt;/span&gt;&lt;span&gt; rustup update stable&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;what-is-the-never-type&quot;&gt;What is the &lt;code&gt;never&lt;/code&gt; type?&lt;/h2&gt;
&lt;p&gt;&lt;code&gt;!&lt;/code&gt; is a type with no values (hence the &lt;code&gt;never&lt;/code&gt; name duh).&lt;/p&gt;
&lt;p&gt;It represents
diverging computations, meaning computations that never resolve to any value.&lt;/p&gt;
&lt;p&gt;Since no value of type &lt;code&gt;!&lt;/code&gt; can ever exist, the compiler treats it as a marker
for unreachable code.&lt;/p&gt;
&lt;p&gt;Expressions that terminate control flow have type &lt;code&gt;!&lt;/code&gt;: &lt;code&gt;return&lt;/code&gt;, &lt;code&gt;break&lt;/code&gt;,
&lt;code&gt;continue&lt;/code&gt;, &lt;code&gt;panic!&lt;/code&gt;, and infinite &lt;code&gt;loop&lt;/code&gt;s.&lt;/p&gt;
&lt;p&gt;This example is taken verbatim from &lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/std/primitive.never.html&quot;&gt;the never type documentation&lt;/a&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; meow&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; u32&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;    let&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; _&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; !&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; return&lt;/span&gt;&lt;span class=&quot;z-l-9 z-d-12&quot;&gt; 123&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-10 z-l-i z-d-5 z-d-i&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-i z-d-5 z-d-i&quot;&gt; code following the `return` is unreachable...&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-10 z-l-i z-d-5 z-d-i&quot;&gt;    //&lt;/span&gt;&lt;span class=&quot;z-l-10 z-l-i z-d-5 z-d-i&quot;&gt; since it returns from the function&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Why does this typecheck? The &lt;code&gt;return 123&lt;/code&gt; expression returns from the
function right there, so the binding never happens and the code after it
never runs.&lt;/p&gt;
&lt;p&gt;The binding itself is pointless, but it shows that a &lt;code&gt;return&lt;/code&gt;
expression has type &lt;code&gt;!&lt;/code&gt;, and that you can now name that type in a type
annotation.&lt;/p&gt;
&lt;h2 id=&quot;how-can-we-use-this-type&quot;&gt;How can we use this type?&lt;/h2&gt;
&lt;p&gt;Before 1.100.0, if the body of a function returning anything other than &lt;code&gt;()&lt;/code&gt; or &lt;code&gt;!&lt;/code&gt; was an infinite
loop, the compiler demanded a trailing return value:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; anyhow&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;Error&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; tokio&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;io&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span&gt;copy_bidirectional&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; tokio&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;net&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;TcpListener&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpStream&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;use&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; tracing&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span&gt;debug&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span&gt; warn&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; proxy&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpListener&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Result&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Error&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    loop&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;        let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;accept&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;        debug!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; connected&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;        if&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt; let&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Err&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; fwd&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;            warn!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; ended: &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;e:#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;    Ok&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; fwd&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; sock&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpStream&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Result&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Error&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;    let&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt; mut&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; out&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpStream&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;::&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;connect&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;up&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;    copy_bidirectional&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;mut&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; out&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;    Ok&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;The loop can only exit through &lt;code&gt;?&lt;/code&gt;, which returns
early, so the &lt;code&gt;Ok(())&lt;/code&gt; sits after code that never finishes.&lt;/p&gt;
&lt;p&gt;But in editions
before 2024 the compiler could not express that in stable types.&lt;/p&gt;
&lt;p&gt;The type of
the loop fell back to &lt;code&gt;()&lt;/code&gt;, and &lt;code&gt;()&lt;/code&gt; does not match &lt;code&gt;Result&amp;lt;(), Error&amp;gt;&lt;/code&gt;, so
the compiler required a value at the end of the function, hence the &lt;code&gt;Ok(())&lt;/code&gt; return value.&lt;/p&gt;
&lt;p&gt;Now the same function needs nothing after the loop:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; proxy&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpListener&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Result&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Error&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    loop&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;        let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;accept&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;        debug!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; connected&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;        if&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt; let&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Err&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; fwd&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;            warn!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; ended: &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;e:#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Wait, why can we do this?&lt;/p&gt;
&lt;p&gt;Version 1.100.0 changes the never type fallback from &lt;code&gt;()&lt;/code&gt; to &lt;code&gt;!&lt;/code&gt; across all editions.
The infinite loop is now properly typed as &lt;code&gt;!&lt;/code&gt;, and &lt;code&gt;!&lt;/code&gt;
coerces to any type, including &lt;code&gt;Result&amp;lt;(), Error&amp;gt;&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The function typechecks
with nothing after the loop, because there is genuinely nothing left to say.&lt;/p&gt;
&lt;p&gt;You can go one step further and make the signature itself honest:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;async&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; proxy&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; TcpListener&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; &amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;str&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; -&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Result&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Error&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    loop&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;        let&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; (&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; ln&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;accept&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;?&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;        debug!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; connected&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;        if&lt;/span&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt; let&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Err&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; fwd&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;sock&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; up&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;            warn!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;addr&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt; ended: &lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;{&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;e:#&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;        }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;    }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;Result&amp;lt;!, Error&amp;gt;&lt;/code&gt; declares that the &lt;code&gt;Ok&lt;/code&gt; variant can
never be constructed, since it would have to hold a value of type &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The
function either returns &lt;code&gt;Err(e)&lt;/code&gt; through &lt;code&gt;?&lt;/code&gt;, or it never returns at all.
Callers benefit: the compiler knows &lt;code&gt;Ok&lt;/code&gt; cannot exist, so they can match
without an &lt;code&gt;Ok&lt;/code&gt; arm:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;match&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; proxy&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;ln&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;127.0.0.1:8080&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;    Err&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; log_and_exit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since &lt;code&gt;Ok&lt;/code&gt; can never be constructed, the &lt;code&gt;Err(e)&lt;/code&gt; pattern is irrefutable,
so callers can even skip the match and bind the error directly:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Err&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; proxy&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;ln&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; &amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-7 z-d-9&quot;&gt;127.0.0.1:8080&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;quot;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;.&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;await&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;log_and_exit&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;e&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;&lt;h2 id=&quot;traits-for&quot;&gt;Traits for “!”&lt;/h2&gt;
&lt;p&gt;You can implement your own traits for &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;At first glance this
seems pointless, since many trait methods take &lt;code&gt;self&lt;/code&gt;, and calling a method
on &lt;code&gt;!&lt;/code&gt; is impossible: no value exists to call it with. The point is to satisfy trait bounds when &lt;code&gt;!&lt;/code&gt; is used as a generic argument.&lt;/p&gt;
&lt;p&gt;Say you have an &lt;code&gt;App&lt;/code&gt; that may hold a &lt;code&gt;Plugin&lt;/code&gt;:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;trait&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Plugin&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; App&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Plugin&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;    plugin&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Option&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;P&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;,&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Before, how it was done:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;struct&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; NoPlugin&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;impl&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Plugin&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; NoPlugin&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; app&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; App&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt;NoPlugin&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; App&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; plugin&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; None&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;&lt;code&gt;App&amp;lt;P: Plugin&amp;gt;&lt;/code&gt; demands a type for &lt;code&gt;P&lt;/code&gt; that implements
the trait, even when the app ships with no plugin at all.&lt;/p&gt;
&lt;p&gt;Without &lt;code&gt;!&lt;/code&gt; on
stable, there was no empty type to point at. The only way through was to
invent a dummy struct whose &lt;code&gt;run&lt;/code&gt; does nothing, purely to satisfy the bound.&lt;/p&gt;
&lt;p&gt;Now, how we can do something like this:&lt;/p&gt;
&lt;pre class=&quot;giallo z-l-code z-d-code&quot; &gt;&lt;code data-lang=&quot;rust&quot;&gt;&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;impl&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; Plugin&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; for&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt; !&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;    fn&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; run&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;(&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;&amp;amp;&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;)&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; *&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt;self&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; }&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;}&lt;/span&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;/span&gt;
&lt;span class=&quot;giallo-l&quot;&gt;&lt;span class=&quot;z-l-13 z-d-18&quot;&gt;let&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; app&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; App&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;lt;&lt;/span&gt;&lt;span class=&quot;z-l-12 z-d-17&quot;&gt;!&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;&amp;gt;&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt; =&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; App&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; {&lt;/span&gt;&lt;span class=&quot;z-l-1 z-d-3&quot;&gt; plugin&lt;/span&gt;&lt;span class=&quot;z-l-2 z-d-4&quot;&gt;:&lt;/span&gt;&lt;span class=&quot;z-l-15 z-d-16&quot;&gt; None&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt; }&lt;/span&gt;&lt;span class=&quot;z-l-8 z-d-7&quot;&gt;;&lt;/span&gt;&lt;/span&gt;&lt;/code&gt;&lt;/pre&gt;
&lt;p&gt;Since &lt;code&gt;!&lt;/code&gt; has no values, you can implement your own traits for
it, as long as their methods take some form of &lt;code&gt;self&lt;/code&gt;.&lt;/p&gt;
&lt;p&gt;The body &lt;code&gt;*self&lt;/code&gt; looks
alarming but is sound: dereferencing &lt;code&gt;self: &amp;amp;!&lt;/code&gt; would produce a value of type
&lt;code&gt;!&lt;/code&gt;, and no such value can exist, so the code is statically unreachable. It
coerces to whatever the method returns, and the compiler is satisfied. No
dummy type cluttering the API, and the bound is satisfied for free.&lt;/p&gt;
&lt;p&gt;The &lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/reference/implementations.html#orphan-rules&quot;&gt;orphan rule&lt;/a&gt; still applies: &lt;code&gt;!&lt;/code&gt; is a primitive type from &lt;code&gt;std&lt;/code&gt;, so you
cannot implement foreign traits like &lt;code&gt;Debug&lt;/code&gt; for it in your own crate.&lt;/p&gt;
&lt;p&gt;The
good news is that 1.100.0 makes &lt;code&gt;std&lt;/code&gt; itself implement the important ones,
&lt;code&gt;Clone&lt;/code&gt;, &lt;code&gt;Debug&lt;/code&gt;, &lt;code&gt;Display&lt;/code&gt;, &lt;code&gt;PartialEq&lt;/code&gt;, &lt;code&gt;Error&lt;/code&gt;, so bounds on types like
&lt;code&gt;Result&amp;lt;T, !&amp;gt;&lt;/code&gt; are satisfied out of the box.&lt;/p&gt;
&lt;p&gt;As a rule of thumb from the standard library docs: if a trait only has
methods taking &lt;code&gt;self&lt;/code&gt;, &lt;code&gt;&amp;amp;self&lt;/code&gt;, or other &lt;code&gt;Self&lt;/code&gt;-typed arguments, consider
implementing it for &lt;code&gt;!&lt;/code&gt;.&lt;/p&gt;
&lt;h2 id=&quot;references&quot;&gt;References&lt;/h2&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/std/primitive.never.html&quot;&gt;The never type, Rust standard library documentation&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://blog.rust-lang.org/2026/11/12/Rust-1.100.0/#never-type&quot;&gt;Announcing Rust 1.100.0, Rust blog&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/book/appendix-07-nightly-rust.html&quot;&gt;Nightly Rust, The Rust Book appendix&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a rel=&quot;external&quot; href=&quot;https://doc.rust-lang.org/reference/implementations.html#orphan-rules&quot;&gt;Orphan rules, The Rust Reference&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
</content>
        
    </entry>
</feed>
