<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Api-Design on rustbites</title><link>https://www.rustbites.com/tags/api-design/</link><description>Recent content in Api-Design on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Tue, 09 Jun 2026 22:09:02 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/api-design/index.xml" rel="self" type="application/rss+xml"/><item><title>192. impl Into&lt;String&gt; — Take Owned or Borrowed Without an Extra Allocation</title><link>https://www.rustbites.com/posts/bite-192/</link><pubDate>Tue, 09 Jun 2026 17:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-192/</guid><description>&lt;p&gt;Bite 191 said: if you only &lt;em&gt;read&lt;/em&gt; the argument, take &lt;code&gt;&amp;amp;str&lt;/code&gt;. But what if you need to &lt;em&gt;store&lt;/em&gt; it? Taking &lt;code&gt;&amp;amp;str&lt;/code&gt; and calling &lt;code&gt;.to_owned()&lt;/code&gt; always allocates — even when the caller handed you a &lt;code&gt;String&lt;/code&gt; it was about to throw away. &lt;code&gt;impl Into&amp;lt;String&amp;gt;&lt;/code&gt; fixes that.&lt;/p&gt;</description></item><item><title>191. Accept &amp;str, Not String — Take the Most General Borrow</title><link>https://www.rustbites.com/posts/bite-191/</link><pubDate>Tue, 09 Jun 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-191/</guid><description>&lt;p&gt;A function that takes &lt;code&gt;String&lt;/code&gt; forces every caller holding a &lt;code&gt;&amp;amp;str&lt;/code&gt; to allocate just to call you. Take &lt;code&gt;&amp;amp;str&lt;/code&gt; instead — and &lt;code&gt;&amp;amp;[T]&lt;/code&gt; over &lt;code&gt;&amp;amp;Vec&amp;lt;T&amp;gt;&lt;/code&gt; — and deref coercion lets everyone in for free.&lt;/p&gt;</description></item></channel></rss>