mirror of
https://github.com/edg-l/edlang.git
synced 2024-11-23 00:18:24 +00:00
128 lines
29 KiB
HTML
128 lines
29 KiB
HTML
<!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="API documentation for the Rust `OsStrExt` trait in crate `clap_lex`."><title>OsStrExt in clap_lex - Rust</title><script> if (window.location.protocol !== "file:") document.write(`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceSerif4-Regular-46f98efaafac5295.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Regular-018c141bf0843ffd.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/FiraSans-Medium-8f9a781e4970d388.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2"><link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2">`)</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-e935ef01ae1c1829.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.78.0 (9b00956e5 2024-04-29)" data-channel="1.78.0" data-search-js="search-42d8da7a6b9792c2.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-4c98445ec4002617.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-12cf3b4f4f9dc36d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-04d5337699b92874.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-16x16-8b506e7a72182f1c.png"><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.0</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"><nav class="sub"><form class="search-form"><span></span><div id="sidebar-button" tabindex="-1"><a href="../clap_lex/all.html" title="show sidebar"></a></div><input class="search-input" name="search" aria-label="Run search in the documentation" autocomplete="off" spellcheck="false" placeholder="Click or press ‘S’ to search, ‘?’ for more options…" type="search"><div id="help-button" tabindex="-1"><a href="../help.html" title="help">?</a></div><div id="settings-menu" tabindex="-1"><a href="../settings.html" title="settings"><img width="22" height="22" alt="Change settings" src="../static.files/wheel-7b819b6101059cd0.svg"></a></div></form></nav><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"><img src="../static.files/clipboard-7571035ce49a181d.svg" width="19" height="18" alt="Copy item path"></button></h1><span class="out-of-band"><a class="src" href="../src/clap_lex/ext.rs.html#3-182">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</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>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.78.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.contains" class="fn">contains</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.bool.html">bool</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.find" class="fn">find</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.usize.html">usize</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.strip_prefix" class="fn">strip_prefix</a>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.starts_with" class="fn">starts_with</a>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.bool.html">bool</a>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.split" class="fn">split</a><'s, 'n>(&'s self, needle: &'n <a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> Split<'s, 'n>;
|
||
<span class="item-spacer"></span> fn <a href="#tymethod.split_once" class="fn">split_once</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)>;
|
||
}</code></pre><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#8">source</a><h4 class="code-header">fn <a href="#tymethod.try_str" class="fn">try_str</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.78.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>></h4></section></summary><div class="docblock"><p>Converts to a string slice.</p>
|
||
<p>The Utf8Error 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#23">source</a><h4 class="code-header">fn <a href="#tymethod.contains" class="fn">contains</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.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#48">source</a><h4 class="code-header">fn <a href="#tymethod.find" class="fn">find</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.usize.html">usize</a>></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.78.0/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> if the pattern doesn’t 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#65">source</a><h4 class="code-header">fn <a href="#tymethod.strip_prefix" class="fn">strip_prefix</a>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></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#80">source</a><h4 class="code-header">fn <a href="#tymethod.starts_with" class="fn">starts_with</a>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.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#167">source</a><h4 class="code-header">fn <a href="#tymethod.split" class="fn">split</a><'s, 'n>(&'s self, needle: &'n <a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> Split<'s, 'n></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<<span class="kw">_</span>> = 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<<span class="kw">_</span>> = 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<<span class="kw">_</span>> = 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<<span class="kw">_</span>> = 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<<span class="kw">_</span>> = x.split(<span class="string">"|"</span>).collect();
|
||
|
||
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&</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<<span class="kw">_</span>> = x.split(<span class="string">"/"</span>).collect();
|
||
|
||
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&</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<<span class="kw">_</span>> = 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">&</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<<span class="kw">_</span>> = OsStr::new(<span class="string">"rust"</span>).split(<span class="string">""</span>).collect();
|
||
<span class="macro">assert_eq!</span>(f, <span class="kw-2">&</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<<span class="kw">_</span>> = x.split(<span class="string">" "</span>).collect();
|
||
|
||
<span class="macro">assert_eq!</span>(d, <span class="kw-2">&</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">&</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.78.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#181">source</a><h4 class="code-header">fn <a href="#tymethod.split_once" class="fn">split_once</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)></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#184-238">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.78.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#185-188">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>(&self) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>, <a class="struct" href="https://doc.rust-lang.org/1.78.0/core/str/error/struct.Utf8Error.html" title="struct core::str::error::Utf8Error">Utf8Error</a>></h4></section><section id="method.contains" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#190-192">source</a><a href="#method.contains" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.contains" class="fn">contains</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.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#194-198">source</a><a href="#method.find" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.find" class="fn">find</a>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.usize.html">usize</a>></h4></section><section id="method.strip_prefix" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#200-208">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>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></h4></section><section id="method.starts_with" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#209-212">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>(&self, prefix: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="primitive" href="https://doc.rust-lang.org/1.78.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#214-220">source</a><a href="#method.split" class="anchor">§</a><h4 class="code-header">fn <a href="#tymethod.split" class="fn">split</a><'s, 'n>(&'s self, needle: &'n <a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> Split<'s, 'n></h4></section><section id="method.split_once" class="method trait-impl"><a class="src rightside" href="../src/clap_lex/ext.rs.html#222-237">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>(&self, needle: &<a class="primitive" href="https://doc.rust-lang.org/1.78.0/std/primitive.str.html">str</a>) -> <a class="enum" href="https://doc.rust-lang.org/1.78.0/core/option/enum.Option.html" title="enum core::option::Option">Option</a><(&<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>, &<a class="struct" href="https://doc.rust-lang.org/1.78.0/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>)></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> |