<p dir="auto">A couple weeks ago we discussed being able to 'chain' task spawn options, which would be much more fun to write than the current builder interface.</p>
<p dir="auto">I envision:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="fn unlinked() -&gt; builder { ... }
fn notify_chan() -&gt; builder { ... }
fn spawn() { ... }

impl for builder {
    fn unlinked() -&gt; builder {
        { link: false with builder }
    }
    fn notify_chan(chan) -&gt; builder 
    ...
    fn spawn() ...
}"><pre class="notranslate"><code class="notranslate">fn unlinked() -&gt; builder { ... }
fn notify_chan() -&gt; builder { ... }
fn spawn() { ... }

impl for builder {
    fn unlinked() -&gt; builder {
        { link: false with builder }
    }
    fn notify_chan(chan) -&gt; builder 
    ...
    fn spawn() ...
}
</code></pre></div>
<p dir="auto">With the functions at the top level returning a default set. Then you'll never need to type "builder" - all of these will be valid:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="do task::spawn { ... }
do task::unlinked().notify_chan(c).spawn { ... }
do task::notify_chan(c).unlinked().spawn { ... }
let t = task::unlinked();
do t.spawn { ... }
do t.notify_chan(c).spawn { ... }"><pre class="notranslate"><code class="notranslate">do task::spawn { ... }
do task::unlinked().notify_chan(c).spawn { ... }
do task::notify_chan(c).unlinked().spawn { ... }
let t = task::unlinked();
do t.spawn { ... }
do t.notify_chan(c).spawn { ... }
</code></pre></div>
<p dir="auto">One problem is noncopyability of certain things that might get put in builder - like wrappers and notify ports (or future stuff...? not entirely clear on that).</p>
<p dir="auto">Move mode on self can solve that; until then, we could perhaps make it a runtime error by doing the standard option dance. (When move mode on self appears, we can make it a build error without changing the interface.)</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="type builder = ~mut option&lt;{...record...}&gt;
impl for builder {
    fn set_noncopyable_thing() -&gt; builder {
        let mut result = none;
        result &lt;-&gt; *self;
    }
}"><pre class="notranslate"><code class="notranslate">type builder = ~mut option&lt;{...record...}&gt;
impl for builder {
    fn set_noncopyable_thing() -&gt; builder {
        let mut result = none;
        result &lt;-&gt; *self;
    }
}
</code></pre></div>
<p dir="auto">An attempt to use a builder with <code class="notranslate">none</code> in it would fail at runtime.</p>
<p dir="auto">I didn't find any duplicate issue, but this problem has probably been there for a long time.</p>
<ul dir="auto">
<li>The code <code class="notranslate">panic!("{}", 7)</code> compiles and prints <code class="notranslate">thread &lt;main&gt; panicked at "7", ...</code></li>
<li>The code <code class="notranslate">panic!("{} {}", 7)</code> doesn't compile as an argument is missing</li>
<li>The code <code class="notranslate">panic!("{}")</code> <strong>does compile</strong> and prints <code class="notranslate">thread &lt;main&gt; panicked at "{}", ...</code></li>
</ul>
<p dir="auto">The last one doesn't detect potential mistakes, and is inconsistent with <code class="notranslate">println!("{}")</code> which doesn't compile.</p>