<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>Idioms on rustbites</title><link>https://www.rustbites.com/tags/idioms/</link><description>Recent content in Idioms on rustbites</description><generator>Hugo</generator><language>en</language><lastBuildDate>Sun, 28 Jun 2026 10:27:19 +0200</lastBuildDate><atom:link href="https://www.rustbites.com/tags/idioms/index.xml" rel="self" type="application/rss+xml"/><item><title>227. trim_matches — Strip the Same Char Off Both Ends, However Many There Are</title><link>https://www.rustbites.com/posts/bite-227/</link><pubDate>Sun, 28 Jun 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-227/</guid><description>&lt;p&gt;&lt;code&gt;trim()&lt;/code&gt; only knows about whitespace, and &lt;code&gt;strip_prefix&lt;/code&gt; peels off one occurrence. When you need to shave &lt;em&gt;every&lt;/em&gt; leading and trailing &lt;code&gt;.&lt;/code&gt; (or &lt;code&gt;0&lt;/code&gt;, or quote) off a string, reach for &lt;code&gt;trim_matches&lt;/code&gt;.&lt;/p&gt;</description></item><item><title>226. unwrap_or_default — Stop Spelling Out the Empty Value</title><link>https://www.rustbites.com/posts/bite-226/</link><pubDate>Sat, 27 Jun 2026 17:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-226/</guid><description>&lt;p&gt;Writing &lt;code&gt;.unwrap_or(0)&lt;/code&gt; or &lt;code&gt;.unwrap_or_else(String::new)&lt;/code&gt; to fall back to an empty value? If the type already has a &lt;code&gt;Default&lt;/code&gt;, &lt;code&gt;unwrap_or_default&lt;/code&gt; says it for you.&lt;/p&gt;</description></item><item><title>225. Option::map_or — Transform-or-Default in One Call, Skip the match</title><link>https://www.rustbites.com/posts/bite-225/</link><pubDate>Sat, 27 Jun 2026 09:00:00 +0100</pubDate><guid>https://www.rustbites.com/posts/bite-225/</guid><description>&lt;p&gt;Reaching for a four-line &lt;code&gt;match&lt;/code&gt; just to turn an &lt;code&gt;Option&lt;/code&gt; into a plain value? &lt;code&gt;map_or&lt;/code&gt; does the transform &lt;em&gt;and&lt;/em&gt; the fallback in a single call.&lt;/p&gt;</description></item></channel></rss>