<p dir="auto">Now that the <code class="notranslate">Default</code> trait has been added for handling <code class="notranslate">{}</code> format, there are two ways to define how to convert an object to a string: <code class="notranslate">foo.to_str()</code> and <code class="notranslate">format!("{}", foo)</code>; that is, the object needs to implement both <code class="notranslate">ToStr</code> and <code class="notranslate">Default</code>.</p>
<p dir="auto">The proposal is to eliminate this duplication by eliminating <code class="notranslate">ToStr</code> and, instead, implementing <code class="notranslate">to_str()</code> by internally invoking the formatting function. This of course would be a major breaking change to existing code.</p>
<p dir="auto">An alternative would be to provide a "default implementation" for the <code class="notranslate">Default</code> trait for anything implementing <code class="notranslate">ToStr</code>. This would be a backward-compatible change but would require extending the type system to allow for allowing default implementation of traits (if the type implements some other traits) with the ability to override the implementation for specific types.</p>
<p dir="auto">When developing inside of libstd, it's a lot more convenient to be able to <code class="notranslate">make check-stage0-std</code> instead of <code class="notranslate">make check-stage2-std</code>. But every now and again, we lose the ability to do that to some obscure linker error which can languish for a long time because the test suite doesn't make sure that it works.</p>
<p dir="auto">Currently it is broken due to this:</p>
<div class="snippet-clipboard-content notranslate position-relative overflow-auto" data-snippet-clipboard-copy-content="error: duplicate entry for `str_eq`
error: aborting due to previous error"><pre class="notranslate"><code class="notranslate">error: duplicate entry for `str_eq`
error: aborting due to previous error
</code></pre></div>