edlang/clap_lex/trait.OsStrExt.html
2024-07-26 09:44:36 +00:00

128 lines
28 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="String-like methods for `OsStr`"><title>OsStrExt in clap_lex - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="clap_lex" data-themes="" data-resource-suffix="" data-rustdoc-version="1.80.0 (051478957 2024-07-21)" data-channel="1.80.0" data-search-js="search-d52510db62a78183.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../clap_lex/index.html">clap_lex</a><span class="version">0.7.2</span></h2></div><h2 class="location"><a href="#">OsStrExt</a></h2><div class="sidebar-elems"><section><h3><a href="#required-methods">Required Methods</a></h3><ul class="block"><li><a href="#tymethod.contains">contains</a></li><li><a href="#tymethod.find">find</a></li><li><a href="#tymethod.split">split</a></li><li><a href="#tymethod.split_once">split_once</a></li><li><a href="#tymethod.starts_with">starts_with</a></li><li><a href="#tymethod.strip_prefix">strip_prefix</a></li><li><a href="#tymethod.try_str">try_str</a></li></ul><h3><a href="#foreign-impls">Implementations on Foreign Types</a></h3><ul class="block"><li><a href="#impl-OsStrExt-for-OsStr">OsStr</a></li></ul><h3><a href="#implementors">Implementors</a></h3></section><h2><a href="index.html">In crate clap_lex</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Trait <a href="index.html">clap_lex</a>::<wbr><a class="trait" href="#">OsStrExt</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/clap_lex/ext.rs.html#4-183">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>&#x2212;</span>]</button></span></div><pre class="rust item-decl"><code>pub trait OsStrExt: Sealed {
// Required methods
fn <a href="#tymethod.try_str" class="fn">try_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.contains" class="fn">contains</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.find" class="fn">find</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.strip_prefix" class="fn">strip_prefix</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.starts_with" class="fn">starts_with</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>;
<span class="item-spacer"></span> fn <a href="#tymethod.split" class="fn">split</a>&lt;'s, 'n&gt;(&amp;'s self, needle: &amp;'n <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; Split&lt;'s, 'n&gt;;
<span class="item-spacer"></span> fn <a href="#tymethod.split_once" class="fn">split_once</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)&gt;;
}</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>String-like methods for <a href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr"><code>OsStr</code></a></p>
</div></details><h2 id="required-methods" class="section-header">Required Methods<a href="#required-methods" class="anchor">§</a></h2><div class="methods"><details class="toggle method-toggle" open><summary><section id="tymethod.try_str" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#9">source</a><h4 class="code-header">fn <a href="#tymethod.try_str" class="fn">try_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>&gt;</h4></section></summary><div class="docblock"><p>Converts to a string slice.</p>
<p>The <code>Utf8Error</code> is guaranteed to have a valid UTF8 boundary
in its <code>valid_up_to()</code></p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.contains" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#24">source</a><h4 class="code-header">fn <a href="#tymethod.contains" class="fn">contains</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the given pattern matches a sub-slice of
this string slice.</p>
<p>Returns <code>false</code> if it does not.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>bananas = std::ffi::OsStr::new(<span class="string">"bananas"</span>);
<span class="macro">assert!</span>(bananas.contains(<span class="string">"nana"</span>));
<span class="macro">assert!</span>(!bananas.contains(<span class="string">"apples"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.find" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#49">source</a><h4 class="code-header">fn <a href="#tymethod.find" class="fn">find</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>&gt;</h4></section></summary><div class="docblock"><p>Returns the byte index of the first character of this string slice that
matches the pattern.</p>
<p>Returns <a href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> if the pattern doesnt match.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>s = std::ffi::OsStr::new(<span class="string">"Löwe 老虎 Léopard Gepardi"</span>);
<span class="macro">assert_eq!</span>(s.find(<span class="string">"L"</span>), <span class="prelude-val">Some</span>(<span class="number">0</span>));
<span class="macro">assert_eq!</span>(s.find(<span class="string">"é"</span>), <span class="prelude-val">Some</span>(<span class="number">14</span>));
<span class="macro">assert_eq!</span>(s.find(<span class="string">"par"</span>), <span class="prelude-val">Some</span>(<span class="number">17</span>));</code></pre></div>
<p>Not finding the pattern:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>s = std::ffi::OsStr::new(<span class="string">"Löwe 老虎 Léopard"</span>);
<span class="macro">assert_eq!</span>(s.find(<span class="string">"1"</span>), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.strip_prefix" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#66">source</a><h4 class="code-header">fn <a href="#tymethod.strip_prefix" class="fn">strip_prefix</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt;</h4></section></summary><div class="docblock"><p>Returns a string slice with the prefix removed.</p>
<p>If the string starts with the pattern <code>prefix</code>, returns substring after the prefix, wrapped
in <code>Some</code>.</p>
<p>If the string does not start with <code>prefix</code>, returns <code>None</code>.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"foo:bar"</span>).strip_prefix(<span class="string">"foo:"</span>), <span class="prelude-val">Some</span>(OsStr::new(<span class="string">"bar"</span>)));
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"foo:bar"</span>).strip_prefix(<span class="string">"bar"</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"foofoo"</span>).strip_prefix(<span class="string">"foo"</span>), <span class="prelude-val">Some</span>(OsStr::new(<span class="string">"foo"</span>)));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.starts_with" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#81">source</a><h4 class="code-header">fn <a href="#tymethod.starts_with" class="fn">starts_with</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the given pattern matches a prefix of this
string slice.</p>
<p>Returns <code>false</code> if it does not.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>bananas = std::ffi::OsStr::new(<span class="string">"bananas"</span>);
<span class="macro">assert!</span>(bananas.starts_with(<span class="string">"bana"</span>));
<span class="macro">assert!</span>(!bananas.starts_with(<span class="string">"nana"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.split" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#168">source</a><h4 class="code-header">fn <a href="#tymethod.split" class="fn">split</a>&lt;'s, 'n&gt;(&amp;'s self, needle: &amp;'n <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; Split&lt;'s, 'n&gt;</h4></section></summary><div class="docblock"><p>An iterator over substrings of this string slice, separated by
characters matched by a pattern.</p>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<p>Simple patterns:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>v: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">"Mary had a little lamb"</span>).split(<span class="string">" "</span>).collect();
<span class="macro">assert_eq!</span>(v, [OsStr::new(<span class="string">"Mary"</span>), OsStr::new(<span class="string">"had"</span>), OsStr::new(<span class="string">"a"</span>), OsStr::new(<span class="string">"little"</span>), OsStr::new(<span class="string">"lamb"</span>)]);
<span class="kw">let </span>v: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">""</span>).split(<span class="string">"X"</span>).collect();
<span class="macro">assert_eq!</span>(v, [OsStr::new(<span class="string">""</span>)]);
<span class="kw">let </span>v: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">"lionXXtigerXleopard"</span>).split(<span class="string">"X"</span>).collect();
<span class="macro">assert_eq!</span>(v, [OsStr::new(<span class="string">"lion"</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"tiger"</span>), OsStr::new(<span class="string">"leopard"</span>)]);
<span class="kw">let </span>v: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">"lion::tiger::leopard"</span>).split(<span class="string">"::"</span>).collect();
<span class="macro">assert_eq!</span>(v, [OsStr::new(<span class="string">"lion"</span>), OsStr::new(<span class="string">"tiger"</span>), OsStr::new(<span class="string">"leopard"</span>)]);</code></pre></div>
<p>If a string contains multiple contiguous separators, you will end up
with empty strings in the output:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>x = OsStr::new(<span class="string">"||||a||b|c"</span>);
<span class="kw">let </span>d: Vec&lt;<span class="kw">_</span>&gt; = x.split(<span class="string">"|"</span>).collect();
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"a"</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"b"</span>), OsStr::new(<span class="string">"c"</span>)]);</code></pre></div>
<p>Contiguous separators are separated by the empty string.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>x = OsStr::new(<span class="string">"(///)"</span>);
<span class="kw">let </span>d: Vec&lt;<span class="kw">_</span>&gt; = x.split(<span class="string">"/"</span>).collect();
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">"("</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">")"</span>)]);</code></pre></div>
<p>Separators at the start or end of a string are neighbored
by empty strings.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>d: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">"010"</span>).split(<span class="string">"0"</span>).collect();
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"1"</span>), OsStr::new(<span class="string">""</span>)]);</code></pre></div>
<p>When the empty string is used as a separator, it panics</p>
<div class="example-wrap should_panic"><a href="#" class="tooltip" title="This example panics"></a><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>f: Vec&lt;<span class="kw">_</span>&gt; = OsStr::new(<span class="string">"rust"</span>).split(<span class="string">""</span>).collect();
<span class="macro">assert_eq!</span>(f, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"r"</span>), OsStr::new(<span class="string">"u"</span>), OsStr::new(<span class="string">"s"</span>), OsStr::new(<span class="string">"t"</span>), OsStr::new(<span class="string">""</span>)]);</code></pre></div>
<p>Contiguous separators can lead to possibly surprising behavior
when whitespace is used as the separator. This code is correct:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="kw">let </span>x = OsStr::new(<span class="string">" a b c"</span>);
<span class="kw">let </span>d: Vec&lt;<span class="kw">_</span>&gt; = x.split(<span class="string">" "</span>).collect();
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"a"</span>), OsStr::new(<span class="string">""</span>), OsStr::new(<span class="string">"b"</span>), OsStr::new(<span class="string">"c"</span>)]);</code></pre></div>
<p>It does <em>not</em> give you:</p>
<div class="example-wrap ignore"><a href="#" class="tooltip" title="This example is not tested"></a><pre class="rust rust-example-rendered"><code><span class="macro">assert_eq!</span>(d, <span class="kw-2">&amp;</span>[OsStr::new(<span class="string">"a"</span>), OsStr::new(<span class="string">"b"</span>), OsStr::new(<span class="string">"c"</span>)]);</code></pre></div>
<p>Use <a href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html#method.split_whitespace" title="method str::split_whitespace"><code>split_whitespace</code></a> for this behavior.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="tymethod.split_once" class="method"><a class="src rightside" href="../src/clap_lex/ext.rs.html#182">source</a><h4 class="code-header">fn <a href="#tymethod.split_once" class="fn">split_once</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)&gt;</h4></section></summary><div class="docblock"><p>Splits the string on the first occurrence of the specified delimiter and
returns prefix before delimiter and suffix after delimiter.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::ffi::OsStr;
<span class="kw">use </span>clap_lex::OsStrExt <span class="kw">as _</span>;
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"cfg"</span>).split_once(<span class="string">"="</span>), <span class="prelude-val">None</span>);
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"cfg="</span>).split_once(<span class="string">"="</span>), <span class="prelude-val">Some</span>((OsStr::new(<span class="string">"cfg"</span>), OsStr::new(<span class="string">""</span>))));
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"cfg=foo"</span>).split_once(<span class="string">"="</span>), <span class="prelude-val">Some</span>((OsStr::new(<span class="string">"cfg"</span>), OsStr::new(<span class="string">"foo"</span>))));
<span class="macro">assert_eq!</span>(OsStr::new(<span class="string">"cfg=foo=bar"</span>).split_once(<span class="string">"="</span>), <span class="prelude-val">Some</span>((OsStr::new(<span class="string">"cfg"</span>), OsStr::new(<span class="string">"foo=bar"</span>))));</code></pre></div>
</div></details></div><h2 id="foreign-impls" class="section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor">§</a></h2><details class="toggle implementors-toggle"><summary><section id="impl-OsStrExt-for-OsStr" class="impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#185-239">source</a><a href="#impl-OsStrExt-for-OsStr" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="trait.OsStrExt.html" title="trait clap_lex::OsStrExt">OsStrExt</a> for <a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a></h3></section></summary><div class="impl-items"><section id="method.try_str" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#186-189">source</a><a href="#method.try_str" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.try_str" class="fn">try_str</a>(&amp;self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.80.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>&gt;</h4></section><section id="method.contains" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#191-193">source</a><a href="#method.contains" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.contains" class="fn">contains</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section><section id="method.find" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#195-199">source</a><a href="#method.find" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.find" class="fn">find</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.usize.html">usize</a>&gt;</h4></section><section id="method.strip_prefix" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#201-209">source</a><a href="#method.strip_prefix" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.strip_prefix" class="fn">strip_prefix</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>&gt;</h4></section><section id="method.starts_with" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#210-213">source</a><a href="#method.starts_with" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.starts_with" class="fn">starts_with</a>(&amp;self, prefix: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a></h4></section><section id="method.split" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#215-221">source</a><a href="#method.split" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.split" class="fn">split</a>&lt;'s, 'n&gt;(&amp;'s self, needle: &amp;'n <a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; Split&lt;'s, 'n&gt;</h4></section><section id="method.split_once" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#223-238">source</a><a href="#method.split_once" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.split_once" class="fn">split_once</a>(&amp;self, needle: &amp;<a class="primitive" href="https://doc.rust-lang.org/1.80.0/std/primitive.str.html">str</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.80.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;(&amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &amp;<a class="struct" href="https://doc.rust-lang.org/1.80.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)&gt;</h4></section></div></details><h2 id="implementors" class="section-header">Implementors<a href="#implementors" class="anchor">§</a></h2><div id="implementors-list"></div><script src="../trait.impl/clap_lex/ext/trait.OsStrExt.js" data-ignore-extern-crates="std" async></script></section></div></main></body></html>