<!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 `StrExt` trait in crate `odds`.">
<meta name="keywords" content="rust, rustlang, rust-lang, StrExt">
<title>odds::string::StrExt - Rust</title>
<link rel="stylesheet" type="text/css" href="../../normalize.css">
<link rel="stylesheet" type="text/css" href="../../rustdoc.css">
<link rel="stylesheet" type="text/css" href="../../main.css">
</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">
<p class='location'><a href='../index.html'>odds</a>::<wbr><a href='index.html'>string</a></p><script>window.sidebarCurrent = {name: 'StrExt', ty: 'trait', relpath: ''};</script><script defer src="sidebar-items.js"></script>
</nav>
<nav class="sub">
<form class="search-form js-only">
<div class="search-container">
<input class="search-input" name="search"
autocomplete="off"
placeholder="Click or press ‘S’ to search, ‘?’ for more options…"
type="search">
</div>
</form>
</nav>
<section id='main' class="content">
<h1 class='fqn'><span class='in-band'>Trait <a href='../index.html'>odds</a>::<wbr><a href='index.html'>string</a>::<wbr><a class="trait" href=''>StrExt</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'>−</span>]
</a>
</span><a class='srclink' href='../../src/odds/string.rs.html#12-50' title='goto source code'>[src]</a></span></h1>
<pre class='rust trait'>pub trait StrExt {
fn <a href='#tymethod.rep' class='fnname'>rep</a>(&self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/collections/string/struct.String.html" title="struct collections::string::String">String</a>;
fn <a href='#tymethod.append' class='fnname'>append</a>(&self, s: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/collections/string/struct.String.html" title="struct collections::string::String">String</a>;
fn <a href='#tymethod.prefixes' class='fnname'>prefixes</a>(&self) -> <a class="struct" href="../../odds/string/struct.Prefixes.html" title="struct odds::string::Prefixes">Prefixes</a>;
fn <a href='#tymethod.suffixes' class='fnname'>suffixes</a>(&self) -> <a class="struct" href="../../odds/string/struct.Suffixes.html" title="struct odds::string::Suffixes">Suffixes</a>;
fn <a href='#tymethod.substrings' class='fnname'>substrings</a>(&self) -> <a class="struct" href="../../odds/string/struct.Substrings.html" title="struct odds::string::Substrings">Substrings</a>;
fn <a href='#tymethod.is_acceptable_index' class='fnname'>is_acceptable_index</a>(&self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>;
}</pre><div class='docblock'><p>Extra methods for <code>str</code></p>
</div>
<h2 id='required-methods'>Required Methods</h2>
<div class='methods'>
<h3 id='tymethod.rep' class='method'><span id='rep.v' class='invisible'><code>fn <a href='#tymethod.rep' class='fnname'>rep</a>(&self, n: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/collections/string/struct.String.html" title="struct collections::string::String">String</a></code></span></h3><div class='docblock'><p>Repeat the string <code>n</code> times.</p>
<p>Requires <code>feature="std"</code></p>
</div><h3 id='tymethod.append' class='method'><span id='append.v' class='invisible'><code>fn <a href='#tymethod.append' class='fnname'>append</a>(&self, s: &<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>) -> <a class="struct" href="https://doc.rust-lang.org/nightly/collections/string/struct.String.html" title="struct collections::string::String">String</a></code></span></h3><div class='docblock'><p>Requires <code>feature="std"</code></p>
</div><h3 id='tymethod.prefixes' class='method'><span id='prefixes.v' class='invisible'><code>fn <a href='#tymethod.prefixes' class='fnname'>prefixes</a>(&self) -> <a class="struct" href="../../odds/string/struct.Prefixes.html" title="struct odds::string::Prefixes">Prefixes</a></code></span></h3><div class='docblock'><p>All non-empty prefixes</p>
</div><h3 id='tymethod.suffixes' class='method'><span id='suffixes.v' class='invisible'><code>fn <a href='#tymethod.suffixes' class='fnname'>suffixes</a>(&self) -> <a class="struct" href="../../odds/string/struct.Suffixes.html" title="struct odds::string::Suffixes">Suffixes</a></code></span></h3><div class='docblock'><p>All non-empty suffixes</p>
</div><h3 id='tymethod.substrings' class='method'><span id='substrings.v' class='invisible'><code>fn <a href='#tymethod.substrings' class='fnname'>substrings</a>(&self) -> <a class="struct" href="../../odds/string/struct.Substrings.html" title="struct odds::string::Substrings">Substrings</a></code></span></h3><div class='docblock'><p>Produce all non-empty substrings</p>
</div><h3 id='tymethod.is_acceptable_index' class='method'><span id='is_acceptable_index.v' class='invisible'><code>fn <a href='#tymethod.is_acceptable_index' class='fnname'>is_acceptable_index</a>(&self, index: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.usize.html">usize</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></code></span></h3><div class='docblock'><p>Return <code>true</code> if <code>index</code> is acceptable for slicing the string.</p>
<p>Acceptable indices are byte offsets from the start of the string
that mark the start of an encoded utf-8 sequence, or an index equal
to <code>self.len()</code>.</p>
<p>Return <code>false</code> if the index is out of bounds.</p>
<p>For example the string <code>"Abcαβγ"</code> has length is 9 and the acceptable
indices are <em>0, 1, 2, 3, 5, 7,</em> and <em>9</em>.</p>
<pre class="rust rust-example-rendered">
<span class="kw">use</span> <span class="ident">odds</span>::<span class="ident">string</span>::<span class="ident">StrExt</span>;
<span class="kw">for</span> <span class="kw-2">&</span><span class="ident">ix</span> <span class="kw">in</span> <span class="kw-2">&</span>[<span class="number">0</span>, <span class="number">1</span>, <span class="number">2</span>, <span class="number">3</span>, <span class="number">5</span>, <span class="number">7</span>, <span class="number">9</span>] {
<span class="macro">assert</span><span class="macro">!</span>(<span class="string">"Abcαβγ"</span>.<span class="ident">is_acceptable_index</span>(<span class="ident">ix</span>));
}</pre>
</div></div>
<h2 id='implementors'>Implementors</h2>
<ul class='item-list' id='implementors-list'>
<li><code>impl StrExt for <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a></code></li>
</ul><script type="text/javascript" async
src="../../implementors/odds/string/trait.StrExt.js">
</script></section>
<section id='search' class="content hidden"></section>
<section class="footer"></section>
<aside id="help" class="hidden">
<div>
<h1 class="hidden">Help</h1>
<div class="shortcuts">
<h2>Keyboard Shortcuts</h2>
<dl>
<dt>?</dt>
<dd>Show this help dialog</dd>
<dt>S</dt>
<dd>Focus the search field</dd>
<dt>⇤</dt>
<dd>Move up in search results</dd>
<dt>⇥</dt>
<dd>Move down in search results</dd>
<dt>⏎</dt>
<dd>Go to active search result</dd>
<dt>+</dt>
<dd>Collapse/expand all sections</dd>
</dl>
</div>
<div class="infos">
<h2>Search Tricks</h2>
<p>
Prefix searches with a type followed by a colon (e.g.
<code>fn:</code>) to restrict the search to a given type.
</p>
<p>
Accepted types are: <code>fn</code>, <code>mod</code>,
<code>struct</code>, <code>enum</code>,
<code>trait</code>, <code>type</code>, <code>macro</code>,
and <code>const</code>.
</p>
<p>
Search functions by type signature (e.g.
<code>vec -> usize</code> or <code>* -> vec</code>)
</p>
</div>
</div>
</aside>
<script>
window.rootPath = "../../";
window.currentCrate = "odds";
</script>
<script src="../../jquery.js"></script>
<script src="../../main.js"></script>
<script defer src="../../search-index.js"></script>
</body>
</html>