Files
rapr-rs/docs/case/trait.CaseExt.html
2021-03-26 19:20:48 +00:00

53 lines
16 KiB
HTML
Raw Permalink 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="API documentation for the Rust `CaseExt` trait in crate `case`."><meta name="keywords" content="rust, rustlang, rust-lang, CaseExt"><title>case::CaseExt - Rust</title><link rel="stylesheet" type="text/css" href="../normalize.css"><link rel="stylesheet" type="text/css" href="../rustdoc.css" id="mainThemeStyle"><link rel="stylesheet" type="text/css" href="../light.css" id="themeStyle"><link rel="stylesheet" type="text/css" href="../dark.css" disabled ><link rel="stylesheet" type="text/css" href="../ayu.css" disabled ><script id="default-settings"></script><script src="../storage.js"></script><noscript><link rel="stylesheet" href="../noscript.css"></noscript><link rel="icon" type="image/svg+xml" href="../favicon.svg">
<link rel="alternate icon" type="image/png" href="../favicon-16x16.png">
<link rel="alternate icon" type="image/png" href="../favicon-32x32.png"><style type="text/css">#crate-search{background-image:url("../down-arrow.svg");}</style></head><body class="rustdoc trait"><!--[if lte IE 8]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="sidebar"><div class="sidebar-menu">&#9776;</div><a href='../case/index.html'><div class='logo-container rust-logo'><img src='../rust-logo.png' alt='logo'></div></a><p class="location">Trait CaseExt</p><div class="sidebar-elems"><div class="block items"><a class="sidebar-title" href="#associated-types">Associated Types</a><div class="sidebar-links"><a href="#associatedtype.Owned">Owned</a></div><a class="sidebar-title" href="#required-methods">Required Methods</a><div class="sidebar-links"><a href="#tymethod.to_capitalized">to_capitalized</a><a href="#tymethod.to_camel">to_camel</a><a href="#tymethod.to_camel_lowercase">to_camel_lowercase</a><a href="#tymethod.to_snake">to_snake</a><a href="#tymethod.to_dashed">to_dashed</a></div><a class="sidebar-title" href="#foreign-impls">Implementations on Foreign Types</a><div class="sidebar-links"><a href="#impl-CaseExt-for-str">str</a></div><a class="sidebar-title" href="#implementors">Implementors</a></div><p class="location"><a href="index.html">case</a></p><div id="sidebar-vars" data-name="CaseExt" data-ty="trait" data-relpath=""></div><script defer src="sidebar-items.js"></script></div></nav><div class="theme-picker"><button id="theme-picker" aria-label="Pick another theme!" aria-haspopup="menu"><img src="../brush.svg" width="18" alt="Pick another theme!"></button><div id="theme-choices" role="menu"></div></div><script src="../theme.js"></script><nav class="sub"><form class="search-form"><div class="search-container"><div><select id="crate-search"><option value="All crates">All crates</option></select><input class="search-input" name="search" disabled autocomplete="off" spellcheck="false" placeholder="Click or press S to search, ? for more options…" type="search"></div><button type="button" class="help-button">?</button>
<a id="settings-menu" href="../settings.html"><img src="../wheel.svg" width="18" alt="Change settings"></a></div></form></nav><section id="main" class="content"><h1 class="fqn"><span class="in-band">Trait <a href="index.html">case</a>::<wbr><a class="trait" href="">CaseExt</a></span><span class="out-of-band"><span id="render-detail"><a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs">[<span class="inner">&#x2212;</span>]</a></span><a class="srclink" href="../src/case/lib.rs.html#3-71" title="goto source code">[src]</a></span></h1><div class="docblock type-decl hidden-by-usual-hider"><pre class="rust trait">pub trait CaseExt {
type <a href="#associatedtype.Owned" class="type">Owned</a>;
fn <a href="#tymethod.to_capitalized" class="fnname">to_capitalized</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.to_camel" class="fnname">to_camel</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.to_camel_lowercase" class="fnname">to_camel_lowercase</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.to_snake" class="fnname">to_snake</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a>;
<div class="item-spacer"></div> fn <a href="#tymethod.to_dashed" class="fnname">to_dashed</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a>;
}</pre></div><h2 id="associated-types" class="small-section-header">Associated Types<a href="#associated-types" class="anchor"></a></h2><div class="methods"><h3 id="associatedtype.Owned" class="method"><code>type <a href="#associatedtype.Owned" class="type">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#4" title="goto source code">[src]</a></h3></div><span class="loading-content">Loading content...</span><h2 id="required-methods" class="small-section-header">Required methods<a href="#required-methods" class="anchor"></a></h2><div class="methods"><h3 id="tymethod.to_capitalized" class="method"><code>fn <a href="#tymethod.to_capitalized" class="fnname">to_capitalized</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#17" title="goto source code">[src]</a></h3><div class="docblock"><p>Create a new string from a string slice with replacing the first character with its
to ASCII upper case counterpart (if one exists).</p>
<h1 id="examples" class="section-header"><a href="#examples">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">case</span>::<span class="ident">CaseExt</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="ident">CaseExt</span>::<span class="ident">to_capitalized</span>(<span class="string">&quot;stringy string&quot;</span>), <span class="string">&quot;Stringy string&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="ident">CaseExt</span>::<span class="ident">to_capitalized</span>(<span class="string">&quot;言語&quot;</span>), <span class="string">&quot;言語&quot;</span>);</pre></div>
</div><h3 id="tymethod.to_camel" class="method"><code>fn <a href="#tymethod.to_camel" class="fnname">to_camel</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#31" title="goto source code">[src]</a></h3><div class="docblock"><p>Convert a string slice from snake case to a new capitalized camel case string.</p>
<h1 id="examples-1" class="section-header"><a href="#examples-1">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">case</span>::<span class="ident">CaseExt</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;a_string_and_a_miss&quot;</span>.<span class="ident">to_camel</span>(), <span class="string">&quot;AStringAndAMiss&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;fooby&quot;</span>.<span class="ident">to_camel</span>(), <span class="string">&quot;Fooby&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;_wild__underscore_s_&quot;</span>.<span class="ident">to_camel</span>(), <span class="string">&quot;WildUnderscoreS&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;言_語&quot;</span>.<span class="ident">to_camel</span>(), <span class="string">&quot;言語&quot;</span>);</pre></div>
</div><h3 id="tymethod.to_camel_lowercase" class="method"><code>fn <a href="#tymethod.to_camel_lowercase" class="fnname">to_camel_lowercase</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#45" title="goto source code">[src]</a></h3><div class="docblock"><p>Convert a string slice from snake case to a new uncapitalized camel case string.</p>
<h1 id="examples-2" class="section-header"><a href="#examples-2">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">case</span>::<span class="ident">CaseExt</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;string_henry_iii&quot;</span>.<span class="ident">to_camel_lowercase</span>(), <span class="string">&quot;stringHenryIii&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;fooby&quot;</span>.<span class="ident">to_camel_lowercase</span>(), <span class="string">&quot;fooby&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;_wild__underscore_s_&quot;</span>.<span class="ident">to_camel_lowercase</span>(), <span class="string">&quot;WildUnderscoreS&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;言_語&quot;</span>.<span class="ident">to_camel_lowercase</span>(), <span class="string">&quot;言語&quot;</span>);</pre></div>
</div><h3 id="tymethod.to_snake" class="method"><code>fn <a href="#tymethod.to_snake" class="fnname">to_snake</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#59" title="goto source code">[src]</a></h3><div class="docblock"><p>Convert a string from camel case to snake case.</p>
<h1 id="examples-3" class="section-header"><a href="#examples-3">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">case</span>::<span class="ident">CaseExt</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;martinLutherStringJr&quot;</span>.<span class="ident">to_snake</span>(), <span class="string">&quot;martin_luther_string_jr&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;fooby&quot;</span>.<span class="ident">to_snake</span>(), <span class="string">&quot;fooby&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;WildUnderscoreS&quot;</span>.<span class="ident">to_snake</span>(), <span class="string">&quot;wild_underscore_s&quot;</span>);
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;言語&quot;</span>.<span class="ident">to_snake</span>(), <span class="string">&quot;言語&quot;</span>);</pre></div>
</div><h3 id="tymethod.to_dashed" class="method"><code>fn <a href="#tymethod.to_dashed" class="fnname">to_dashed</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#70" title="goto source code">[src]</a></h3><div class="docblock"><p>Replaces underscores with dashes in a string.</p>
<h1 id="examples-4" class="section-header"><a href="#examples-4">Examples</a></h1>
<div class="example-wrap"><pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">case</span>::<span class="ident">CaseExt</span>;
<span class="macro">assert_eq</span><span class="macro">!</span>(<span class="kw-2">&amp;</span><span class="string">&quot;stringing_in_the_rain&quot;</span>.<span class="ident">to_dashed</span>(), <span class="string">&quot;stringing-in-the-rain&quot;</span>);</pre></div>
</div></div><span class="loading-content">Loading content...</span><h2 id="foreign-impls" class="small-section-header">Implementations on Foreign Types<a href="#foreign-impls" class="anchor"></a></h2><h3 id="impl-CaseExt-for-str" class="impl"><code class="in-band">impl <a class="trait" href="../case/trait.CaseExt.html" title="trait case::CaseExt">CaseExt</a> for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code><a href="#impl-CaseExt-for-str" class="anchor"></a><a class="srclink" href="../src/case/lib.rs.html#73-130" title="goto source code">[src]</a></h3><div class="impl-items"><h4 id="associatedtype.Owned-1" class="type"><code>type <a href="#associatedtype.Owned" class="type">Owned</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code></h4><h4 id="method.to_capitalized" class="method hidden"><code>fn <a href="#method.to_capitalized" class="fnname">to_capitalized</a>(&amp;self) -&gt; Self::<a class="type" href="../case/trait.CaseExt.html#associatedtype.Owned" title="type case::CaseExt::Owned">Owned</a></code><a class="srclink" href="../src/case/lib.rs.html#76-88" title="goto source code">[src]</a></h4><h4 id="method.to_camel" class="method hidden"><code>fn <a href="#method.to_camel" class="fnname">to_camel</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="../src/case/lib.rs.html#90-92" title="goto source code">[src]</a></h4><h4 id="method.to_camel_lowercase" class="method hidden"><code>fn <a href="#method.to_camel_lowercase" class="fnname">to_camel_lowercase</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="../src/case/lib.rs.html#94-96" title="goto source code">[src]</a></h4><h4 id="method.to_snake" class="method hidden"><code>fn <a href="#method.to_snake" class="fnname">to_snake</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="../src/case/lib.rs.html#98-116" title="goto source code">[src]</a></h4><h4 id="method.to_dashed" class="method hidden"><code>fn <a href="#method.to_dashed" class="fnname">to_dashed</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/nightly/alloc/string/struct.String.html" title="struct alloc::string::String">String</a></code><a class="srclink" href="../src/case/lib.rs.html#118-129" title="goto source code">[src]</a></h4></div><span class="loading-content">Loading content...</span><h2 id="implementors" class="small-section-header">Implementors<a href="#implementors" class="anchor"></a></h2><div class="item-list" id="implementors-list"></div><span class="loading-content">Loading content...</span><script type="text/javascript" src="../implementors/case/trait.CaseExt.js" async></script></section><section id="search" class="content hidden"></section><section class="footer"></section><div id="rustdoc-vars" data-root-path="../" data-current-crate="case"></div>
<script src="../main.js"></script><script defer src="../search-index.js"></script></body></html>