<!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 `char` primitive in crate `std`."> <meta name="keywords" content="rust, rustlang, rust-lang, char"> <title>char - 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"> <link rel="shortcut icon" href="https://doc.rust-lang.org/favicon.ico"> </head> <body class="rustdoc primitive"> <!--[if lte IE 8]> <div class="warning"> This old browser is unsupported and will most likely display funky things. </div> <![endif]--> <nav class="sidebar"> <a href='../std/index.html'><img src='https://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png' alt='logo' width='100'></a> <p class='location'>Primitive Type char</p><div class="block items"><ul><li><a href="#methods">Methods</a></li><li><a href="#implementations">Trait Implementations</a></li></ul></div><p class='location'><a href='index.html'>std</a></p><script>window.sidebarCurrent = {name: 'char', ty: 'primitive', 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'>Primitive Type <a class="primitive" href=''>char</a></span><span class='out-of-band'><span class='since' title='Stable since Rust version 1.0.0'>1.0.0</span><span id='render-detail'> <a id="toggle-all-docs" href="javascript:void(0)" title="collapse all docs"> [<span class='inner'>−</span>] </a> </span></span></h1> <div class='docblock'><p>A character type.</p> <p>The <code>char</code> type represents a single character. More specifically, since 'character' isn't a well-defined concept in Unicode, <code>char</code> is a '<a href="http://www.unicode.org/glossary/#unicode_scalar_value">Unicode scalar value</a>', which is similar to, but not the same as, a '<a href="http://www.unicode.org/glossary/#code_point">Unicode code point</a>'.</p> <p>This documentation describes a number of methods and trait implementations on the <code>char</code> type. For technical reasons, there is additional, separate documentation in <a href="char/index.html">the <code>std::char</code> module</a> as well.</p> <h1 id='representation' class='section-header'><a href='#representation'>Representation</a></h1> <p><code>char</code> is always four bytes in size. This is a different representation than a given character would have as part of a <a href="string/struct.String.html"><code>String</code></a>. For example:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">v</span> <span class="op">=</span> <span class="macro">vec</span><span class="macro">!</span>[<span class="string">'h'</span>, <span class="string">'e'</span>, <span class="string">'l'</span>, <span class="string">'l'</span>, <span class="string">'o'</span>]; <span class="comment">// five elements times four bytes for each element</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">20</span>, <span class="ident">v</span>.<span class="ident">len</span>() <span class="op">*</span> <span class="ident">std</span>::<span class="ident">mem</span>::<span class="ident">size_of</span>::<span class="op"><</span><span class="ident">char</span><span class="op">></span>()); <span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from</span>(<span class="string">"hello"</span>); <span class="comment">// five elements times one byte per element</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">5</span>, <span class="ident">s</span>.<span class="ident">len</span>() <span class="op">*</span> <span class="ident">std</span>::<span class="ident">mem</span>::<span class="ident">size_of</span>::<span class="op"><</span><span class="ident">u8</span><span class="op">></span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20v%20%3D%20vec!%5B'h'%2C%20'e'%2C%20'l'%2C%20'l'%2C%20'o'%5D%3B%0A%0A%2F%2F%20five%20elements%20times%20four%20bytes%20for%20each%20element%0Aassert_eq!(20%2C%20v.len()%20*%20std%3A%3Amem%3A%3Asize_of%3A%3A%3Cchar%3E())%3B%0A%0Alet%20s%20%3D%20String%3A%3Afrom(%22hello%22)%3B%0A%0A%2F%2F%20five%20elements%20times%20one%20byte%20per%20element%0Aassert_eq!(5%2C%20s.len()%20*%20std%3A%3Amem%3A%3Asize_of%3A%3A%3Cu8%3E())%3B%0A%7D">Run</a></pre> <p>As always, remember that a human intuition for 'character' may not map to Unicode's definitions. For example, emoji symbols such as '❤️' can be more than one Unicode code point; this ❤️ in particular is two:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from</span>(<span class="string">"❤️"</span>); <span class="comment">// we get two chars out of a single ❤️</span> <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">iter</span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">chars</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">'\u{2764}'</span>), <span class="ident">iter</span>.<span class="ident">next</span>()); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">Some</span>(<span class="string">'\u{fe0f}'</span>), <span class="ident">iter</span>.<span class="ident">next</span>()); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="prelude-val">None</span>, <span class="ident">iter</span>.<span class="ident">next</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20s%20%3D%20String%3A%3Afrom(%22%E2%9D%A4%EF%B8%8F%22)%3B%0A%0A%2F%2F%20we%20get%20two%20chars%20out%20of%20a%20single%20%E2%9D%A4%EF%B8%8F%0Alet%20mut%20iter%20%3D%20s.chars()%3B%0Aassert_eq!(Some('%5Cu%7B2764%7D')%2C%20iter.next())%3B%0Aassert_eq!(Some('%5Cu%7Bfe0f%7D')%2C%20iter.next())%3B%0Aassert_eq!(None%2C%20iter.next())%3B%0A%7D">Run</a></pre> <p>This means it won't fit into a <code>char</code>. Trying to create a literal with <code>let heart = '❤️';</code> gives an error:</p> <pre><code class="language-text">error: character literal may only contain one codepoint: '❤ let heart = '❤️'; ^~ </code></pre> <p>Another implication of the 4-byte fixed size of a <code>char</code> is that per-<code>char</code> processing can end up using a lot more memory:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">s</span> <span class="op">=</span> <span class="ident">String</span>::<span class="ident">from</span>(<span class="string">"love: ❤️"</span>); <span class="kw">let</span> <span class="ident">v</span>: <span class="ident">Vec</span><span class="op"><</span><span class="ident">char</span><span class="op">></span> <span class="op">=</span> <span class="ident">s</span>.<span class="ident">chars</span>().<span class="ident">collect</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">12</span>, <span class="ident">s</span>.<span class="ident">len</span>() <span class="op">*</span> <span class="ident">std</span>::<span class="ident">mem</span>::<span class="ident">size_of</span>::<span class="op"><</span><span class="ident">u8</span><span class="op">></span>()); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">32</span>, <span class="ident">v</span>.<span class="ident">len</span>() <span class="op">*</span> <span class="ident">std</span>::<span class="ident">mem</span>::<span class="ident">size_of</span>::<span class="op"><</span><span class="ident">char</span><span class="op">></span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20s%20%3D%20String%3A%3Afrom(%22love%3A%20%E2%9D%A4%EF%B8%8F%22)%3B%0Alet%20v%3A%20Vec%3Cchar%3E%20%3D%20s.chars().collect()%3B%0A%0Aassert_eq!(12%2C%20s.len()%20*%20std%3A%3Amem%3A%3Asize_of%3A%3A%3Cu8%3E())%3B%0Aassert_eq!(32%2C%20v.len()%20*%20std%3A%3Amem%3A%3Asize_of%3A%3A%3Cchar%3E())%3B%0A%7D">Run</a></pre> </div><h2 id='methods'>Methods</h2><h3 class='impl'><span class='in-band'><code>impl <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/std_unicode/char.rs.html#169-927' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.is_digit' class="method"><span id='is_digit.v' class='invisible'><code>fn <a href='#method.is_digit' class='fnname'>is_digit</a>(self, radix: <a class="primitive" href="primitive.u32.html">u32</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Checks if a <code>char</code> is a digit in the given radix.</p> <p>A 'radix' here is sometimes also called a 'base'. A radix of two indicates a binary number, a radix of ten, decimal, and a radix of sixteen, hexadecimal, to give some common values. Arbitrary radices are supported.</p> <p>Compared to <code>is_numeric()</code>, this function only recognizes the characters <code>0-9</code>, <code>a-z</code> and <code>A-Z</code>.</p> <p>'Digit' is defined to be only the following characters:</p> <ul> <li><code>0-9</code></li> <li><code>a-z</code></li> <li><code>A-Z</code></li> </ul> <p>For a more comprehensive understanding of 'digit', see <a href="#method.is_numeric"><code>is_numeric</code></a>.</p> <h1 id='panics' class='section-header'><a href='#panics'>Panics</a></h1> <p>Panics if given a radix larger than 36.</p> <h1 id='examples' class='section-header'><a href='#examples'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'1'</span>.<span class="ident">is_digit</span>(<span class="number">10</span>)); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'f'</span>.<span class="ident">is_digit</span>(<span class="number">16</span>)); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'f'</span>.<span class="ident">is_digit</span>(<span class="number">10</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('1'.is_digit(10))%3B%0Aassert!('f'.is_digit(16))%3B%0Aassert!(!'f'.is_digit(10))%3B%0A%7D">Run</a></pre> <p>Passing a large radix, causing a panic:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">thread</span>; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">thread</span>::<span class="ident">spawn</span>(<span class="op">||</span> { <span class="comment">// this panics</span> <span class="string">'1'</span>.<span class="ident">is_digit</span>(<span class="number">37</span>); }).<span class="ident">join</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Athread%3B%0A%0Alet%20result%20%3D%20thread%3A%3Aspawn(%7C%7C%20%7B%0A%20%20%20%20%2F%2F%20this%20panics%0A%20%20%20%20'1'.is_digit(37)%3B%0A%7D).join()%3B%0A%0Aassert!(result.is_err())%3B%0A%7D">Run</a></pre> </div><h4 id='method.to_digit' class="method"><span id='to_digit.v' class='invisible'><code>fn <a href='#method.to_digit' class='fnname'>to_digit</a>(self, radix: <a class="primitive" href="primitive.u32.html">u32</a>) -> <a class="enum" href="../std/option/enum.Option.html" title="enum std::option::Option">Option</a><<a class="primitive" href="primitive.u32.html">u32</a>></code></span></h4> <div class='docblock'><p>Converts a <code>char</code> to a digit in the given radix.</p> <p>A 'radix' here is sometimes also called a 'base'. A radix of two indicates a binary number, a radix of ten, decimal, and a radix of sixteen, hexadecimal, to give some common values. Arbitrary radices are supported.</p> <p>'Digit' is defined to be only the following characters:</p> <ul> <li><code>0-9</code></li> <li><code>a-z</code></li> <li><code>A-Z</code></li> </ul> <h1 id='errors' class='section-header'><a href='#errors'>Errors</a></h1> <p>Returns <code>None</code> if the <code>char</code> does not refer to a digit in the given radix.</p> <h1 id='panics-1' class='section-header'><a href='#panics-1'>Panics</a></h1> <p>Panics if given a radix larger than 36.</p> <h1 id='examples-1' class='section-header'><a href='#examples-1'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'1'</span>.<span class="ident">to_digit</span>(<span class="number">10</span>), <span class="prelude-val">Some</span>(<span class="number">1</span>)); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'f'</span>.<span class="ident">to_digit</span>(<span class="number">16</span>), <span class="prelude-val">Some</span>(<span class="number">15</span>));<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('1'.to_digit(10)%2C%20Some(1))%3B%0Aassert_eq!('f'.to_digit(16)%2C%20Some(15))%3B%0A%7D">Run</a></pre> <p>Passing a non-digit results in failure:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'f'</span>.<span class="ident">to_digit</span>(<span class="number">10</span>), <span class="prelude-val">None</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'z'</span>.<span class="ident">to_digit</span>(<span class="number">16</span>), <span class="prelude-val">None</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('f'.to_digit(10)%2C%20None)%3B%0Aassert_eq!('z'.to_digit(16)%2C%20None)%3B%0A%7D">Run</a></pre> <p>Passing a large radix, causing a panic:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">thread</span>; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">thread</span>::<span class="ident">spawn</span>(<span class="op">||</span> { <span class="string">'1'</span>.<span class="ident">to_digit</span>(<span class="number">37</span>); }).<span class="ident">join</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Athread%3B%0A%0Alet%20result%20%3D%20thread%3A%3Aspawn(%7C%7C%20%7B%0A%20%20%20%20'1'.to_digit(37)%3B%0A%7D).join()%3B%0A%0Aassert!(result.is_err())%3B%0A%7D">Run</a></pre> </div><h4 id='method.escape_unicode' class="method"><span id='escape_unicode.v' class='invisible'><code>fn <a href='#method.escape_unicode' class='fnname'>escape_unicode</a>(self) -> <a class="struct" href="../std/char/struct.EscapeUnicode.html" title="struct std::char::EscapeUnicode">EscapeUnicode</a></code></span></h4> <div class='docblock'><p>Returns an iterator that yields the hexadecimal Unicode escape of a character as <code>char</code>s.</p> <p>This will escape characters with the Rust syntax of the form <code>\u{NNNNNN}</code> where <code>NNNNNN</code> is a hexadecimal representation.</p> <h1 id='examples-2' class='section-header'><a href='#examples-2'>Examples</a></h1> <p>As an iterator:</p> <pre class="rust rust-example-rendered"> <span class="kw">for</span> <span class="ident">c</span> <span class="kw">in</span> <span class="string">'❤'</span>.<span class="ident">escape_unicode</span>() { <span class="macro">print</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">c</span>); } <span class="macro">println</span><span class="macro">!</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Afor%20c%20in%20'%E2%9D%A4'.escape_unicode()%20%7B%0A%20%20%20%20print!(%22%7B%7D%22%2C%20c)%3B%0A%7D%0Aprintln!()%3B%0A%7D">Run</a></pre> <p>Using <code>println!</code> directly:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="string">'❤'</span>.<span class="ident">escape_unicode</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%7B%7D%22%2C%20'%E2%9D%A4'.escape_unicode())%3B%0A%7D">Run</a></pre> <p>Both are equivalent to:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"\\u{{2764}}"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%5C%5Cu%7B%7B2764%7D%7D%22)%3B%0A%7D">Run</a></pre> <p>Using <code>to_string</code>:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'❤'</span>.<span class="ident">escape_unicode</span>().<span class="ident">to_string</span>(), <span class="string">"\\u{2764}"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('%E2%9D%A4'.escape_unicode().to_string()%2C%20%22%5C%5Cu%7B2764%7D%22)%3B%0A%7D">Run</a></pre> </div><h4 id='method.escape_debug' class="method"><span id='escape_debug.v' class='invisible'><code>fn <a href='#method.escape_debug' class='fnname'>escape_debug</a>(self) -> <a class="struct" href="../std/char/struct.EscapeDebug.html" title="struct std::char::EscapeDebug">EscapeDebug</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>char_escape_debug </code><a href="https://github.com/rust-lang/rust/issues/35068">#35068</a>)</div></div><div class='docblock'><p>Returns an iterator that yields the literal escape code of a character as <code>char</code>s.</p> <p>This will escape the characters similar to the <code>Debug</code> implementations of <code>str</code> or <code>char</code>.</p> <h1 id='examples-3' class='section-header'><a href='#examples-3'>Examples</a></h1> <p>As an iterator:</p> <pre class="rust rust-example-rendered"> <span class="kw">for</span> <span class="ident">c</span> <span class="kw">in</span> <span class="string">'\n'</span>.<span class="ident">escape_debug</span>() { <span class="macro">print</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">c</span>); } <span class="macro">println</span><span class="macro">!</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Bfeature(char_escape_debug)%5D%0Afn%20main()%20%7B%0Afor%20c%20in%20'%5Cn'.escape_debug()%20%7B%0A%20%20%20%20print!(%22%7B%7D%22%2C%20c)%3B%0A%7D%0Aprintln!()%3B%0A%7D&version=nightly">Run</a></pre> <p>Using <code>println!</code> directly:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="string">'\n'</span>.<span class="ident">escape_debug</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Bfeature(char_escape_debug)%5D%0Afn%20main()%20%7B%0Aprintln!(%22%7B%7D%22%2C%20'%5Cn'.escape_debug())%3B%0A%7D&version=nightly">Run</a></pre> <p>Both are equivalent to:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"\\n"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%5C%5Cn%22)%3B%0A%7D">Run</a></pre> <p>Using <code>to_string</code>:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'\n'</span>.<span class="ident">escape_debug</span>().<span class="ident">to_string</span>(), <span class="string">"\\n"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=%23!%5Bfeature(char_escape_debug)%5D%0Afn%20main()%20%7B%0Aassert_eq!('%5Cn'.escape_debug().to_string()%2C%20%22%5C%5Cn%22)%3B%0A%7D&version=nightly">Run</a></pre> </div><h4 id='method.escape_default' class="method"><span id='escape_default.v' class='invisible'><code>fn <a href='#method.escape_default' class='fnname'>escape_default</a>(self) -> <a class="struct" href="../std/char/struct.EscapeDefault.html" title="struct std::char::EscapeDefault">EscapeDefault</a></code></span></h4> <div class='docblock'><p>Returns an iterator that yields the literal escape code of a character as <code>char</code>s.</p> <p>The default is chosen with a bias toward producing literals that are legal in a variety of languages, including C++11 and similar C-family languages. The exact rules are:</p> <ul> <li>Tab is escaped as <code>\t</code>.</li> <li>Carriage return is escaped as <code>\r</code>.</li> <li>Line feed is escaped as <code>\n</code>.</li> <li>Single quote is escaped as <code>\'</code>.</li> <li>Double quote is escaped as <code>\"</code>.</li> <li>Backslash is escaped as <code>\\</code>.</li> <li>Any character in the 'printable ASCII' range <code>0x20</code> .. <code>0x7e</code> inclusive is not escaped.</li> <li>All other characters are given hexadecimal Unicode escapes; see <a href="#method.escape_unicode"><code>escape_unicode</code></a>.</li> </ul> <h1 id='examples-4' class='section-header'><a href='#examples-4'>Examples</a></h1> <p>As an iterator:</p> <pre class="rust rust-example-rendered"> <span class="kw">for</span> <span class="ident">c</span> <span class="kw">in</span> <span class="string">'"'</span>.<span class="ident">escape_default</span>() { <span class="macro">print</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">c</span>); } <span class="macro">println</span><span class="macro">!</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Afor%20c%20in%20'%22'.escape_default()%20%7B%0A%20%20%20%20print!(%22%7B%7D%22%2C%20c)%3B%0A%7D%0Aprintln!()%3B%0A%7D">Run</a></pre> <p>Using <code>println!</code> directly:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="string">'"'</span>.<span class="ident">escape_default</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%7B%7D%22%2C%20'%22'.escape_default())%3B%0A%7D">Run</a></pre> <p>Both are equivalent to:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"\\\""</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%5C%5C%5C%22%22)%3B%0A%7D">Run</a></pre> <p>Using <code>to_string</code>:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'"'</span>.<span class="ident">escape_default</span>().<span class="ident">to_string</span>(), <span class="string">"\\\""</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('%22'.escape_default().to_string()%2C%20%22%5C%5C%5C%22%22)%3B%0A%7D">Run</a></pre> </div><h4 id='method.len_utf8' class="method"><span id='len_utf8.v' class='invisible'><code>fn <a href='#method.len_utf8' class='fnname'>len_utf8</a>(self) -> <a class="primitive" href="primitive.usize.html">usize</a></code></span></h4> <div class='docblock'><p>Returns the number of bytes this <code>char</code> would need if encoded in UTF-8.</p> <p>That number of bytes is always between 1 and 4, inclusive.</p> <h1 id='examples-5' class='section-header'><a href='#examples-5'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="string">'A'</span>.<span class="ident">len_utf8</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="number">1</span>); <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="string">'ß'</span>.<span class="ident">len_utf8</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="number">2</span>); <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="string">'ℝ'</span>.<span class="ident">len_utf8</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="number">3</span>); <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="string">'💣'</span>.<span class="ident">len_utf8</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="number">4</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20len%20%3D%20'A'.len_utf8()%3B%0Aassert_eq!(len%2C%201)%3B%0A%0Alet%20len%20%3D%20'%C3%9F'.len_utf8()%3B%0Aassert_eq!(len%2C%202)%3B%0A%0Alet%20len%20%3D%20'%E2%84%9D'.len_utf8()%3B%0Aassert_eq!(len%2C%203)%3B%0A%0Alet%20len%20%3D%20'%F0%9F%92%A3'.len_utf8()%3B%0Aassert_eq!(len%2C%204)%3B%0A%7D">Run</a></pre> <p>The <code>&str</code> type guarantees that its contents are UTF-8, and so we can compare the length it would take if each code point was represented as a <code>char</code> vs in the <code>&str</code> itself:</p> <pre class="rust rust-example-rendered"> <span class="comment">// as chars</span> <span class="kw">let</span> <span class="ident">eastern</span> <span class="op">=</span> <span class="string">'東'</span>; <span class="kw">let</span> <span class="ident">capitol</span> <span class="op">=</span> <span class="string">'京'</span>; <span class="comment">// both can be represented as three bytes</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>, <span class="ident">eastern</span>.<span class="ident">len_utf8</span>()); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">3</span>, <span class="ident">capitol</span>.<span class="ident">len_utf8</span>()); <span class="comment">// as a &str, these two are encoded in UTF-8</span> <span class="kw">let</span> <span class="ident">tokyo</span> <span class="op">=</span> <span class="string">"東京"</span>; <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="ident">eastern</span>.<span class="ident">len_utf8</span>() <span class="op">+</span> <span class="ident">capitol</span>.<span class="ident">len_utf8</span>(); <span class="comment">// we can see that they take six bytes total...</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="number">6</span>, <span class="ident">tokyo</span>.<span class="ident">len</span>()); <span class="comment">// ... just like the &str</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="ident">tokyo</span>.<span class="ident">len</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%2F%2F%20as%20chars%0Alet%20eastern%20%3D%20'%E6%9D%B1'%3B%0Alet%20capitol%20%3D%20'%E4%BA%AC'%3B%0A%0A%2F%2F%20both%20can%20be%20represented%20as%20three%20bytes%0Aassert_eq!(3%2C%20eastern.len_utf8())%3B%0Aassert_eq!(3%2C%20capitol.len_utf8())%3B%0A%0A%2F%2F%20as%20a%20%26str%2C%20these%20two%20are%20encoded%20in%20UTF-8%0Alet%20tokyo%20%3D%20%22%E6%9D%B1%E4%BA%AC%22%3B%0A%0Alet%20len%20%3D%20eastern.len_utf8()%20%2B%20capitol.len_utf8()%3B%0A%0A%2F%2F%20we%20can%20see%20that%20they%20take%20six%20bytes%20total...%0Aassert_eq!(6%2C%20tokyo.len())%3B%0A%0A%2F%2F%20...%20just%20like%20the%20%26str%0Aassert_eq!(len%2C%20tokyo.len())%3B%0A%7D">Run</a></pre> </div><h4 id='method.len_utf16' class="method"><span id='len_utf16.v' class='invisible'><code>fn <a href='#method.len_utf16' class='fnname'>len_utf16</a>(self) -> <a class="primitive" href="primitive.usize.html">usize</a></code></span></h4> <div class='docblock'><p>Returns the number of 16-bit code units this <code>char</code> would need if encoded in UTF-16.</p> <p>See the documentation for <a href="#method.len_utf8"><code>len_utf8</code></a> for more explanation of this concept. This function is a mirror, but for UTF-16 instead of UTF-8.</p> <h1 id='examples-6' class='section-header'><a href='#examples-6'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">n</span> <span class="op">=</span> <span class="string">'ß'</span>.<span class="ident">len_utf16</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">n</span>, <span class="number">1</span>); <span class="kw">let</span> <span class="ident">len</span> <span class="op">=</span> <span class="string">'💣'</span>.<span class="ident">len_utf16</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">len</span>, <span class="number">2</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20n%20%3D%20'%C3%9F'.len_utf16()%3B%0Aassert_eq!(n%2C%201)%3B%0A%0Alet%20len%20%3D%20'%F0%9F%92%A3'.len_utf16()%3B%0Aassert_eq!(len%2C%202)%3B%0A%7D">Run</a></pre> </div><h4 id='method.encode_utf8' class="method"><span id='encode_utf8.v' class='invisible'><code>fn <a href='#method.encode_utf8' class='fnname'>encode_utf8</a>(self, dst: <a class="primitive" href="primitive.slice.html">&mut [</a><a class="primitive" href="primitive.u8.html">u8</a><a class="primitive" href="primitive.slice.html">]</a>) -> &mut <a class="primitive" href="primitive.str.html">str</a></code><div class='since' title='Stable since Rust version 1.15.0'>1.15.0</div></span></h4> <div class='docblock'><p>Encodes this character as UTF-8 into the provided byte buffer, and then returns the subslice of the buffer that contains the encoded character.</p> <h1 id='panics-2' class='section-header'><a href='#panics-2'>Panics</a></h1> <p>Panics if the buffer is not large enough. A buffer of length four is large enough to encode any <code>char</code>.</p> <h1 id='examples-7' class='section-header'><a href='#examples-7'>Examples</a></h1> <p>In both of these examples, 'ß' takes two bytes to encode.</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>]; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="string">'ß'</span>.<span class="ident">encode_utf8</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>, <span class="string">"ß"</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">len</span>(), <span class="number">2</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20mut%20b%20%3D%20%5B0%3B%202%5D%3B%0A%0Alet%20result%20%3D%20'%C3%9F'.encode_utf8(%26mut%20b)%3B%0A%0Aassert_eq!(result%2C%20%22%C3%9F%22)%3B%0A%0Aassert_eq!(result.len()%2C%202)%3B%0A%7D">Run</a></pre> <p>A buffer that's too small:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">thread</span>; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">thread</span>::<span class="ident">spawn</span>(<span class="op">||</span> { <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1</span>]; <span class="comment">// this panics</span> <span class="string">'ß'</span>.<span class="ident">encode_utf8</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b</span>); }).<span class="ident">join</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Athread%3B%0A%0Alet%20result%20%3D%20thread%3A%3Aspawn(%7C%7C%20%7B%0A%20%20%20%20let%20mut%20b%20%3D%20%5B0%3B%201%5D%3B%0A%0A%20%20%20%20%2F%2F%20this%20panics%0A%20%20%20'%C3%9F'.encode_utf8(%26mut%20b)%3B%0A%7D).join()%3B%0A%0Aassert!(result.is_err())%3B%0A%7D">Run</a></pre> </div><h4 id='method.encode_utf16' class="method"><span id='encode_utf16.v' class='invisible'><code>fn <a href='#method.encode_utf16' class='fnname'>encode_utf16</a>(self, dst: <a class="primitive" href="primitive.slice.html">&mut [</a><a class="primitive" href="primitive.u16.html">u16</a><a class="primitive" href="primitive.slice.html">]</a>) -> <a class="primitive" href="primitive.slice.html">&mut [</a><a class="primitive" href="primitive.u16.html">u16</a><a class="primitive" href="primitive.slice.html">]</a></code><div class='since' title='Stable since Rust version 1.15.0'>1.15.0</div></span></h4> <div class='docblock'><p>Encodes this character as UTF-16 into the provided <code>u16</code> buffer, and then returns the subslice of the buffer that contains the encoded character.</p> <h1 id='panics-3' class='section-header'><a href='#panics-3'>Panics</a></h1> <p>Panics if the buffer is not large enough. A buffer of length 2 is large enough to encode any <code>char</code>.</p> <h1 id='examples-8' class='section-header'><a href='#examples-8'>Examples</a></h1> <p>In both of these examples, '𝕊' takes two <code>u16</code>s to encode.</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">2</span>]; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="string">'𝕊'</span>.<span class="ident">encode_utf16</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b</span>); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">len</span>(), <span class="number">2</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20mut%20b%20%3D%20%5B0%3B%202%5D%3B%0A%0Alet%20result%20%3D%20'%F0%9D%95%8A'.encode_utf16(%26mut%20b)%3B%0A%0Aassert_eq!(result.len()%2C%202)%3B%0A%7D">Run</a></pre> <p>A buffer that's too small:</p> <pre class="rust rust-example-rendered"> <span class="kw">use</span> <span class="ident">std</span>::<span class="ident">thread</span>; <span class="kw">let</span> <span class="ident">result</span> <span class="op">=</span> <span class="ident">thread</span>::<span class="ident">spawn</span>(<span class="op">||</span> { <span class="kw">let</span> <span class="kw-2">mut</span> <span class="ident">b</span> <span class="op">=</span> [<span class="number">0</span>; <span class="number">1</span>]; <span class="comment">// this panics</span> <span class="string">'𝕊'</span>.<span class="ident">encode_utf16</span>(<span class="kw-2">&</span><span class="kw-2">mut</span> <span class="ident">b</span>); }).<span class="ident">join</span>(); <span class="macro">assert</span><span class="macro">!</span>(<span class="ident">result</span>.<span class="ident">is_err</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Ause%20std%3A%3Athread%3B%0A%0Alet%20result%20%3D%20thread%3A%3Aspawn(%7C%7C%20%7B%0A%20%20%20%20let%20mut%20b%20%3D%20%5B0%3B%201%5D%3B%0A%0A%20%20%20%20%2F%2F%20this%20panics%0A%20%20%20%20'%F0%9D%95%8A'.encode_utf16(%26mut%20b)%3B%0A%7D).join()%3B%0A%0Aassert!(result.is_err())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_alphabetic' class="method"><span id='is_alphabetic.v' class='invisible'><code>fn <a href='#method.is_alphabetic' class='fnname'>is_alphabetic</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is an alphabetic code point, and false if not.</p> <h1 id='examples-9' class='section-header'><a href='#examples-9'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'a'</span>.<span class="ident">is_alphabetic</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'京'</span>.<span class="ident">is_alphabetic</span>()); <span class="kw">let</span> <span class="ident">c</span> <span class="op">=</span> <span class="string">'💝'</span>; <span class="comment">// love is many things, but it is not alphabetic</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="ident">c</span>.<span class="ident">is_alphabetic</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('a'.is_alphabetic())%3B%0Aassert!('%E4%BA%AC'.is_alphabetic())%3B%0A%0Alet%20c%20%3D%20'%F0%9F%92%9D'%3B%0A%2F%2F%20love%20is%20many%20things%2C%20but%20it%20is%20not%20alphabetic%0Aassert!(!c.is_alphabetic())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_xid_start' class="method"><span id='is_xid_start.v' class='invisible'><code>fn <a href='#method.is_xid_start' class='fnname'>is_xid_start</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>unicode</code>)</summary><p>mainly needed for compiler internals</p> </details></div></div><div class='docblock'><p>Returns true if this <code>char</code> satisfies the 'XID_Start' Unicode property, and false otherwise.</p> <p>'XID_Start' is a Unicode Derived Property specified in <a href="http://unicode.org/reports/tr31/#NFKC_Modifications">UAX #31</a>, mostly similar to <code>ID_Start</code> but modified for closure under <code>NFKx</code>.</p> </div><h4 id='method.is_xid_continue' class="method"><span id='is_xid_continue.v' class='invisible'><code>fn <a href='#method.is_xid_continue' class='fnname'>is_xid_continue</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>unicode</code>)</summary><p>mainly needed for compiler internals</p> </details></div></div><div class='docblock'><p>Returns true if this <code>char</code> satisfies the 'XID_Continue' Unicode property, and false otherwise.</p> <p>'XID_Continue' is a Unicode Derived Property specified in <a href="http://unicode.org/reports/tr31/#NFKC_Modifications">UAX #31</a>, mostly similar to 'ID_Continue' but modified for closure under NFKx.</p> </div><h4 id='method.is_lowercase' class="method"><span id='is_lowercase.v' class='invisible'><code>fn <a href='#method.is_lowercase' class='fnname'>is_lowercase</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is lowercase, and false otherwise.</p> <p>'Lowercase' is defined according to the terms of the Unicode Derived Core Property <code>Lowercase</code>.</p> <h1 id='examples-10' class='section-header'><a href='#examples-10'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'a'</span>.<span class="ident">is_lowercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'δ'</span>.<span class="ident">is_lowercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'A'</span>.<span class="ident">is_lowercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'Δ'</span>.<span class="ident">is_lowercase</span>()); <span class="comment">// The various Chinese scripts do not have case, and so:</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'中'</span>.<span class="ident">is_lowercase</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('a'.is_lowercase())%3B%0Aassert!('%CE%B4'.is_lowercase())%3B%0Aassert!(!'A'.is_lowercase())%3B%0Aassert!(!'%CE%94'.is_lowercase())%3B%0A%0A%2F%2F%20The%20various%20Chinese%20scripts%20do%20not%20have%20case%2C%20and%20so%3A%0Aassert!(!'%E4%B8%AD'.is_lowercase())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_uppercase' class="method"><span id='is_uppercase.v' class='invisible'><code>fn <a href='#method.is_uppercase' class='fnname'>is_uppercase</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is uppercase, and false otherwise.</p> <p>'Uppercase' is defined according to the terms of the Unicode Derived Core Property <code>Uppercase</code>.</p> <h1 id='examples-11' class='section-header'><a href='#examples-11'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'a'</span>.<span class="ident">is_uppercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'δ'</span>.<span class="ident">is_uppercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'A'</span>.<span class="ident">is_uppercase</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'Δ'</span>.<span class="ident">is_uppercase</span>()); <span class="comment">// The various Chinese scripts do not have case, and so:</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'中'</span>.<span class="ident">is_uppercase</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!(!'a'.is_uppercase())%3B%0Aassert!(!'%CE%B4'.is_uppercase())%3B%0Aassert!('A'.is_uppercase())%3B%0Aassert!('%CE%94'.is_uppercase())%3B%0A%0A%2F%2F%20The%20various%20Chinese%20scripts%20do%20not%20have%20case%2C%20and%20so%3A%0Aassert!(!'%E4%B8%AD'.is_uppercase())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_whitespace' class="method"><span id='is_whitespace.v' class='invisible'><code>fn <a href='#method.is_whitespace' class='fnname'>is_whitespace</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is whitespace, and false otherwise.</p> <p>'Whitespace' is defined according to the terms of the Unicode Derived Core Property <code>White_Space</code>.</p> <h1 id='examples-12' class='section-header'><a href='#examples-12'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">' '</span>.<span class="ident">is_whitespace</span>()); <span class="comment">// a non-breaking space</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'\u{A0}'</span>.<span class="ident">is_whitespace</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'越'</span>.<span class="ident">is_whitespace</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('%20'.is_whitespace())%3B%0A%0A%2F%2F%20a%20non-breaking%20space%0Aassert!('%5Cu%7BA0%7D'.is_whitespace())%3B%0A%0Aassert!(!'%E8%B6%8A'.is_whitespace())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_alphanumeric' class="method"><span id='is_alphanumeric.v' class='invisible'><code>fn <a href='#method.is_alphanumeric' class='fnname'>is_alphanumeric</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is alphanumeric, and false otherwise.</p> <p>'Alphanumeric'-ness is defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No' and the Derived Core Property 'Alphabetic'.</p> <h1 id='examples-13' class='section-header'><a href='#examples-13'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'٣'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'7'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'৬'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'K'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'و'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'藏'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'¾'</span>.<span class="ident">is_alphanumeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'①'</span>.<span class="ident">is_alphanumeric</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('%D9%A3'.is_alphanumeric())%3B%0Aassert!('7'.is_alphanumeric())%3B%0Aassert!('%E0%A7%AC'.is_alphanumeric())%3B%0Aassert!('K'.is_alphanumeric())%3B%0Aassert!('%D9%88'.is_alphanumeric())%3B%0Aassert!('%E8%97%8F'.is_alphanumeric())%3B%0Aassert!(!'%C2%BE'.is_alphanumeric())%3B%0Aassert!(!'%E2%91%A0'.is_alphanumeric())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_control' class="method"><span id='is_control.v' class='invisible'><code>fn <a href='#method.is_control' class='fnname'>is_control</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is a control code point, and false otherwise.</p> <p>'Control code point' is defined in terms of the Unicode General Category <code>Cc</code>.</p> <h1 id='examples-14' class='section-header'><a href='#examples-14'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="comment">// U+009C, STRING TERMINATOR</span> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">''</span>.<span class="ident">is_control</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'q'</span>.<span class="ident">is_control</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0A%2F%2F%20U%2B009C%2C%20STRING%20TERMINATOR%0Aassert!('%C2%9C'.is_control())%3B%0Aassert!(!'q'.is_control())%3B%0A%7D">Run</a></pre> </div><h4 id='method.is_numeric' class="method"><span id='is_numeric.v' class='invisible'><code>fn <a href='#method.is_numeric' class='fnname'>is_numeric</a>(self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Returns true if this <code>char</code> is numeric, and false otherwise.</p> <p>'Numeric'-ness is defined in terms of the Unicode General Categories 'Nd', 'Nl', 'No'.</p> <h1 id='examples-15' class='section-header'><a href='#examples-15'>Examples</a></h1> <p>Basic usage:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'٣'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'7'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="string">'৬'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'K'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'و'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'藏'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'¾'</span>.<span class="ident">is_numeric</span>()); <span class="macro">assert</span><span class="macro">!</span>(<span class="op">!</span><span class="string">'①'</span>.<span class="ident">is_numeric</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert!('%D9%A3'.is_numeric())%3B%0Aassert!('7'.is_numeric())%3B%0Aassert!('%E0%A7%AC'.is_numeric())%3B%0Aassert!(!'K'.is_numeric())%3B%0Aassert!(!'%D9%88'.is_numeric())%3B%0Aassert!(!'%E8%97%8F'.is_numeric())%3B%0Aassert!(!'%C2%BE'.is_numeric())%3B%0Aassert!(!'%E2%91%A0'.is_numeric())%3B%0A%7D">Run</a></pre> </div><h4 id='method.to_lowercase' class="method"><span id='to_lowercase.v' class='invisible'><code>fn <a href='#method.to_lowercase' class='fnname'>to_lowercase</a>(self) -> <a class="struct" href="../std/char/struct.ToLowercase.html" title="struct std::char::ToLowercase">ToLowercase</a></code></span></h4> <div class='docblock'><p>Returns an iterator that yields the lowercase equivalent of a <code>char</code> as one or more <code>char</code>s.</p> <p>If a character does not have a lowercase equivalent, the same character will be returned back by the iterator.</p> <p>This performs complex unconditional mappings with no tailoring: it maps one Unicode character to its lowercase equivalent according to the <a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt">Unicode database</a> and the additional complex mappings <a href="ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt"><code>SpecialCasing.txt</code></a>. Conditional mappings (based on context or language) are not considered here.</p> <p>For a full reference, see <a href="http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992">here</a>.</p> <h1 id='examples-16' class='section-header'><a href='#examples-16'>Examples</a></h1> <p>As an iterator:</p> <pre class="rust rust-example-rendered"> <span class="kw">for</span> <span class="ident">c</span> <span class="kw">in</span> <span class="string">'İ'</span>.<span class="ident">to_lowercase</span>() { <span class="macro">print</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">c</span>); } <span class="macro">println</span><span class="macro">!</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Afor%20c%20in%20'%C4%B0'.to_lowercase()%20%7B%0A%20%20%20%20print!(%22%7B%7D%22%2C%20c)%3B%0A%7D%0Aprintln!()%3B%0A%7D">Run</a></pre> <p>Using <code>println!</code> directly:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="string">'İ'</span>.<span class="ident">to_lowercase</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%7B%7D%22%2C%20'%C4%B0'.to_lowercase())%3B%0A%7D">Run</a></pre> <p>Both are equivalent to:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"i\u{307}"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22i%5Cu%7B307%7D%22)%3B%0A%7D">Run</a></pre> <p>Using <code>to_string</code>:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'C'</span>.<span class="ident">to_lowercase</span>().<span class="ident">to_string</span>(), <span class="string">"c"</span>); <span class="comment">// Sometimes the result is more than one character:</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'İ'</span>.<span class="ident">to_lowercase</span>().<span class="ident">to_string</span>(), <span class="string">"i\u{307}"</span>); <span class="comment">// Characters that do not have both uppercase and lowercase</span> <span class="comment">// convert into themselves.</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'山'</span>.<span class="ident">to_lowercase</span>().<span class="ident">to_string</span>(), <span class="string">"山"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('C'.to_lowercase().to_string()%2C%20%22c%22)%3B%0A%0A%2F%2F%20Sometimes%20the%20result%20is%20more%20than%20one%20character%3A%0Aassert_eq!('%C4%B0'.to_lowercase().to_string()%2C%20%22i%5Cu%7B307%7D%22)%3B%0A%0A%2F%2F%20Characters%20that%20do%20not%20have%20both%20uppercase%20and%20lowercase%0A%2F%2F%20convert%20into%20themselves.%0Aassert_eq!('%E5%B1%B1'.to_lowercase().to_string()%2C%20%22%E5%B1%B1%22)%3B%0A%7D">Run</a></pre> </div><h4 id='method.to_uppercase' class="method"><span id='to_uppercase.v' class='invisible'><code>fn <a href='#method.to_uppercase' class='fnname'>to_uppercase</a>(self) -> <a class="struct" href="../std/char/struct.ToUppercase.html" title="struct std::char::ToUppercase">ToUppercase</a></code></span></h4> <div class='docblock'><p>Returns an iterator that yields the uppercase equivalent of a <code>char</code> as one or more <code>char</code>s.</p> <p>If a character does not have an uppercase equivalent, the same character will be returned back by the iterator.</p> <p>This performs complex unconditional mappings with no tailoring: it maps one Unicode character to its uppercase equivalent according to the <a href="ftp://ftp.unicode.org/Public/UNIDATA/UnicodeData.txt">Unicode database</a> and the additional complex mappings <a href="ftp://ftp.unicode.org/Public/UNIDATA/SpecialCasing.txt"><code>SpecialCasing.txt</code></a>. Conditional mappings (based on context or language) are not considered here.</p> <p>For a full reference, see <a href="http://www.unicode.org/versions/Unicode7.0.0/ch03.pdf#G33992">here</a>.</p> <h1 id='examples-17' class='section-header'><a href='#examples-17'>Examples</a></h1> <p>As an iterator:</p> <pre class="rust rust-example-rendered"> <span class="kw">for</span> <span class="ident">c</span> <span class="kw">in</span> <span class="string">'ß'</span>.<span class="ident">to_uppercase</span>() { <span class="macro">print</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="ident">c</span>); } <span class="macro">println</span><span class="macro">!</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Afor%20c%20in%20'%C3%9F'.to_uppercase()%20%7B%0A%20%20%20%20print!(%22%7B%7D%22%2C%20c)%3B%0A%7D%0Aprintln!()%3B%0A%7D">Run</a></pre> <p>Using <code>println!</code> directly:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"{}"</span>, <span class="string">'ß'</span>.<span class="ident">to_uppercase</span>());<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22%7B%7D%22%2C%20'%C3%9F'.to_uppercase())%3B%0A%7D">Run</a></pre> <p>Both are equivalent to:</p> <pre class="rust rust-example-rendered"> <span class="macro">println</span><span class="macro">!</span>(<span class="string">"SS"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aprintln!(%22SS%22)%3B%0A%7D">Run</a></pre> <p>Using <code>to_string</code>:</p> <pre class="rust rust-example-rendered"> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'c'</span>.<span class="ident">to_uppercase</span>().<span class="ident">to_string</span>(), <span class="string">"C"</span>); <span class="comment">// Sometimes the result is more than one character:</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'ß'</span>.<span class="ident">to_uppercase</span>().<span class="ident">to_string</span>(), <span class="string">"SS"</span>); <span class="comment">// Characters that do not have both uppercase and lowercase</span> <span class="comment">// convert into themselves.</span> <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="string">'山'</span>.<span class="ident">to_uppercase</span>().<span class="ident">to_string</span>(), <span class="string">"山"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Aassert_eq!('c'.to_uppercase().to_string()%2C%20%22C%22)%3B%0A%0A%2F%2F%20Sometimes%20the%20result%20is%20more%20than%20one%20character%3A%0Aassert_eq!('%C3%9F'.to_uppercase().to_string()%2C%20%22SS%22)%3B%0A%0A%2F%2F%20Characters%20that%20do%20not%20have%20both%20uppercase%20and%20lowercase%0A%2F%2F%20convert%20into%20themselves.%0Aassert_eq!('%E5%B1%B1'.to_uppercase().to_string()%2C%20%22%E5%B1%B1%22)%3B%0A%7D">Run</a></pre> <h1 id='note-on-locale' class='section-header'><a href='#note-on-locale'>Note on locale</a></h1> <p>In Turkish, the equivalent of 'i' in Latin has five forms instead of two:</p> <ul> <li>'Dotless': I / ı, sometimes written ï</li> <li>'Dotted': İ / i</li> </ul> <p>Note that the lowercase dotted 'i' is the same as the Latin. Therefore:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">upper_i</span> <span class="op">=</span> <span class="string">'i'</span>.<span class="ident">to_uppercase</span>().<span class="ident">to_string</span>();<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20upper_i%20%3D%20'i'.to_uppercase().to_string()%3B%0A%7D">Run</a></pre> <p>The value of <code>upper_i</code> here relies on the language of the text: if we're in <code>en-US</code>, it should be <code>"I"</code>, but if we're in <code>tr_TR</code>, it should be <code>"İ"</code>. <code>to_uppercase()</code> does not take this into account, and so:</p> <pre class="rust rust-example-rendered"> <span class="kw">let</span> <span class="ident">upper_i</span> <span class="op">=</span> <span class="string">'i'</span>.<span class="ident">to_uppercase</span>().<span class="ident">to_string</span>(); <span class="macro">assert_eq</span><span class="macro">!</span>(<span class="ident">upper_i</span>, <span class="string">"I"</span>);<a class="test-arrow" target="_blank" href="https://play.rust-lang.org/?code=fn%20main()%20%7B%0Alet%20upper_i%20%3D%20'i'.to_uppercase().to_string()%3B%0A%0Aassert_eq!(upper_i%2C%20%22I%22)%3B%0A%7D">Run</a></pre> <p>holds across languages.</p> </div></div><h2 id='implementations'>Trait Implementations</h2><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/convert/trait.From.html" title="trait std::convert::From">From</a><<a class="primitive" href="primitive.u8.html">u8</a>> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><div class='since' title='Stable since Rust version 1.13.0'>1.13.0</div><a class='srclink' href='../src/core/char.rs.html#204-209' title='goto source code'>[src]</a></span></h3> <div class='docblock'><p>Maps a byte in 0x00...0xFF to a <code>char</code> whose code point has the same value, in U+0000 to U+00FF.</p> <p>Unicode is designed such that this effectively decodes bytes with the character encoding that IANA calls ISO-8859-1. This encoding is compatible with ASCII.</p> <p>Note that this is different from ISO/IEC 8859-1 a.k.a. ISO 8859-1 (with one less hyphen), which leaves some "blanks", byte values that are not assigned to any character. ISO-8859-1 (the IANA one) assigns them to the C0 and C1 control codes.</p> <p>Note that this is <em>also</em> different from Windows-1252 a.k.a. code page 1252, which is a superset ISO/IEC 8859-1 that assigns some (not all!) blanks to punctuation and various Latin characters.</p> <p>To confuse things further, <a href="https://encoding.spec.whatwg.org/">on the Web</a> <code>ascii</code>, <code>iso-8859-1</code>, and <code>windows-1252</code> are all aliases for a superset of Windows-1252 that fills the remaining blanks with corresponding C0 and C1 control codes.</p> </div><div class='impl-items'><h4 id='method.from' class="method"><span id='from.v' class='invisible'><code>fn <a href='../std/convert/trait.From.html#tymethod.from' class='fnname'>from</a>(i: <a class="primitive" href="primitive.u8.html">u8</a>) -> <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Performs the conversion.</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/cmp/trait.Eq.html" title="trait std::cmp::Eq">Eq</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/cmp.rs.html#743' title='goto source code'>[src]</a></span></h3> <div class='impl-items'></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/default/trait.Default.html" title="trait std::default::Default">Default</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/default.rs.html#131-134' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.default' class="method"><span id='default.v' class='invisible'><code>fn <a href='../std/default/trait.Default.html#tymethod.default' class='fnname'>default</a>() -> <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Returns the "default value" for a type. <a href="../std/default/trait.Default.html#tymethod.default">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/fmt/trait.Debug.html" title="trait std::fmt::Debug">Debug</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/fmt/mod.rs.html#1544-1552' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.fmt' class="method"><span id='fmt.v' class='invisible'><code>fn <a href='../std/fmt/trait.Debug.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -> <a class="enum" href="../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="primitive" href="primitive.tuple.html">()</a>, <a class="struct" href="../std/fmt/struct.Error.html" title="struct std::fmt::Error">Error</a>></code></span></h4> <div class='docblock'><p>Formats the value using the given formatter.</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/cmp/trait.Ord.html" title="trait std::cmp::Ord">Ord</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/cmp.rs.html#811-818' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.cmp' class="method"><span id='cmp.v' class='invisible'><code>fn <a href='../std/cmp/trait.Ord.html#tymethod.cmp' class='fnname'>cmp</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="enum" href="../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a></code></span></h4> <div class='docblock'><p>This method returns an <code>Ordering</code> between <code>self</code> and <code>other</code>. <a href="../std/cmp/trait.Ord.html#tymethod.cmp">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/cmp/trait.PartialEq.html" title="trait std::cmp::PartialEq">PartialEq</a><<a class="primitive" href="primitive.char.html">char</a>> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/cmp.rs.html#719-724' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.eq' class="method"><span id='eq.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialEq.html#tymethod.eq' class='fnname'>eq</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used by <code>==</code>. <a href="../std/cmp/trait.PartialEq.html#tymethod.eq">Read more</a></p> </div><h4 id='method.ne' class="method"><span id='ne.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialEq.html#method.ne' class='fnname'>ne</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests for <code>!=</code>.</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/fmt/trait.Display.html" title="trait std::fmt::Display">Display</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/fmt/mod.rs.html#1555-1563' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.fmt-1' class="method"><span id='fmt.v-1' class='invisible'><code>fn <a href='../std/fmt/trait.Display.html#tymethod.fmt' class='fnname'>fmt</a>(&self, f: &mut <a class="struct" href="../std/fmt/struct.Formatter.html" title="struct std::fmt::Formatter">Formatter</a>) -> <a class="enum" href="../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="primitive" href="primitive.tuple.html">()</a>, <a class="struct" href="../std/fmt/struct.Error.html" title="struct std::fmt::Error">Error</a>></code></span></h4> <div class='docblock'><p>Formats the value using the given formatter. <a href="../std/fmt/trait.Display.html#tymethod.fmt">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl<'a> <a class="trait" href="../std/str/pattern/trait.Pattern.html" title="trait std::str::pattern::Pattern">Pattern</a><'a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/str/pattern.rs.html#431-459' title='goto source code'>[src]</a></span></h3> <div class='docblock'><p>Searches for chars that are equal to a given char</p> </div><div class='impl-items'><h4 id='associatedtype.Searcher' class="type"><span id='Searcher.t' class='invisible'><code>type <a href='../std/str/pattern/trait.Pattern.html#associatedtype.Searcher' class="type">Searcher</a> = <a class="struct" href="../std/str/pattern/struct.CharSearcher.html" title="struct std::str::pattern::CharSearcher">CharSearcher</a><'a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>pattern </code><a href="https://github.com/rust-lang/rust/issues/27721">#27721</a>)</summary><p>API not fully fleshed out and ready to be stabilized</p> </details></div></div><div class='docblock'><p>Associated searcher for this pattern</p> </div><h4 id='method.into_searcher' class="method"><span id='into_searcher.v' class='invisible'><code>fn <a href='../std/str/pattern/trait.Pattern.html#tymethod.into_searcher' class='fnname'>into_searcher</a>(self, haystack: &'a <a class="primitive" href="primitive.str.html">str</a>) -> <<a class="primitive" href="primitive.char.html">char</a> as <a class="trait" href="../std/str/pattern/trait.Pattern.html" title="trait std::str::pattern::Pattern">Pattern</a><'a>>::<a class="trait" href="../std/str/pattern/trait.Pattern.html" title="trait std::str::pattern::Pattern">Searcher</a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>pattern </code><a href="https://github.com/rust-lang/rust/issues/27721">#27721</a>)</summary><p>API not fully fleshed out and ready to be stabilized</p> </details></div></div><div class='docblock'><p>Constructs the associated searcher from <code>self</code> and the <code>haystack</code> to search in. <a href="../std/str/pattern/trait.Pattern.html#tymethod.into_searcher">Read more</a></p> </div><h4 id='method.is_contained_in' class="method"><span id='is_contained_in.v' class='invisible'><code>fn <a href='../std/str/pattern/trait.Pattern.html#method.is_contained_in' class='fnname'>is_contained_in</a>(self, haystack: &'a <a class="primitive" href="primitive.str.html">str</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>pattern </code><a href="https://github.com/rust-lang/rust/issues/27721">#27721</a>)</summary><p>API not fully fleshed out and ready to be stabilized</p> </details></div></div><div class='docblock'><p>Checks whether the pattern matches anywhere in the haystack</p> </div><h4 id='method.is_prefix_of' class="method"><span id='is_prefix_of.v' class='invisible'><code>fn <a href='../std/str/pattern/trait.Pattern.html#method.is_prefix_of' class='fnname'>is_prefix_of</a>(self, haystack: &'a <a class="primitive" href="primitive.str.html">str</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>pattern </code><a href="https://github.com/rust-lang/rust/issues/27721">#27721</a>)</summary><p>API not fully fleshed out and ready to be stabilized</p> </details></div></div><div class='docblock'><p>Checks whether the pattern matches at the front of the haystack</p> </div><h4 id='method.is_suffix_of' class="method"><span id='is_suffix_of.v' class='invisible'><code>fn <a href='../std/str/pattern/trait.Pattern.html#method.is_suffix_of' class='fnname'>is_suffix_of</a>(self, haystack: &'a <a class="primitive" href="primitive.str.html">str</a>) -> <a class="primitive" href="primitive.bool.html">bool</a> <span class="where fmt-newline">where<br> <<a class="primitive" href="primitive.char.html">char</a> as <a class="trait" href="../std/str/pattern/trait.Pattern.html" title="trait std::str::pattern::Pattern">Pattern</a><'a>>::<a class="trait" href="../std/str/pattern/trait.Pattern.html" title="trait std::str::pattern::Pattern">Searcher</a>: <a class="trait" href="../std/str/pattern/trait.ReverseSearcher.html" title="trait std::str::pattern::ReverseSearcher">ReverseSearcher</a><'a>, </span></code></span></h4> <div class='stability'><div class='stab unstable'><details><summary><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>pattern </code><a href="https://github.com/rust-lang/rust/issues/27721">#27721</a>)</summary><p>API not fully fleshed out and ready to be stabilized</p> </details></div></div><div class='docblock'><p>Checks whether the pattern matches at the back of the haystack</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/clone/trait.Clone.html" title="trait std::clone::Clone">Clone</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/clone.rs.html#143-147' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.clone' class="method"><span id='clone.v' class='invisible'><code>fn <a href='../std/clone/trait.Clone.html#tymethod.clone' class='fnname'>clone</a>(&self) -> <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Returns a deep copy of the value.</p> </div><h4 id='method.clone_from' class="method"><span id='clone_from.v' class='invisible'><code>fn <a href='../std/clone/trait.Clone.html#method.clone_from' class='fnname'>clone_from</a>(&mut self, source: &Self)</code></span></h4> <div class='docblock'><p>Performs copy-assignment from <code>source</code>. <a href="../std/clone/trait.Clone.html#method.clone_from">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/cmp/trait.PartialOrd.html" title="trait std::cmp::PartialOrd">PartialOrd</a><<a class="primitive" href="primitive.char.html">char</a>> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/cmp.rs.html#795-808' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.partial_cmp' class="method"><span id='partial_cmp.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialOrd.html#tymethod.partial_cmp' class='fnname'>partial_cmp</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="enum" href="../std/option/enum.Option.html" title="enum std::option::Option">Option</a><<a class="enum" href="../std/cmp/enum.Ordering.html" title="enum std::cmp::Ordering">Ordering</a>></code></span></h4> <div class='docblock'><p>This method returns an ordering between <code>self</code> and <code>other</code> values if one exists. <a href="../std/cmp/trait.PartialOrd.html#tymethod.partial_cmp">Read more</a></p> </div><h4 id='method.lt' class="method"><span id='lt.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialOrd.html#method.lt' class='fnname'>lt</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests less than (for <code>self</code> and <code>other</code>) and is used by the <code><</code> operator. <a href="../std/cmp/trait.PartialOrd.html#method.lt">Read more</a></p> </div><h4 id='method.le' class="method"><span id='le.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialOrd.html#method.le' class='fnname'>le</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests less than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code><=</code> operator. <a href="../std/cmp/trait.PartialOrd.html#method.le">Read more</a></p> </div><h4 id='method.ge' class="method"><span id='ge.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialOrd.html#method.ge' class='fnname'>ge</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests greater than or equal to (for <code>self</code> and <code>other</code>) and is used by the <code>>=</code> operator. <a href="../std/cmp/trait.PartialOrd.html#method.ge">Read more</a></p> </div><h4 id='method.gt' class="method"><span id='gt.v' class='invisible'><code>fn <a href='../std/cmp/trait.PartialOrd.html#method.gt' class='fnname'>gt</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>This method tests greater than (for <code>self</code> and <code>other</code>) and is used by the <code>></code> operator. <a href="../std/cmp/trait.PartialOrd.html#method.gt">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><<a class="primitive" href="primitive.u32.html">u32</a>> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/char.rs.html#212-223' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='associatedtype.Error' class="type"><span id='Error.t' class='invisible'><code>type <a href='../std/convert/trait.TryFrom.html#associatedtype.Error' class="type">Error</a> = <a class="struct" href="../std/char/struct.CharTryFromError.html" title="struct std::char::CharTryFromError">CharTryFromError</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from </code><a href="https://github.com/rust-lang/rust/issues/33417">#33417</a>)</div></div><div class='docblock'><p>The type returned in the event of a conversion error.</p> </div><h4 id='method.try_from' class="method"><span id='try_from.v' class='invisible'><code>fn <a href='../std/convert/trait.TryFrom.html#tymethod.try_from' class='fnname'>try_from</a>(i: <a class="primitive" href="primitive.u32.html">u32</a>) -> <a class="enum" href="../std/result/enum.Result.html" title="enum std::result::Result">Result</a><<a class="primitive" href="primitive.char.html">char</a>, <<a class="primitive" href="primitive.char.html">char</a> as <a class="trait" href="../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">TryFrom</a><<a class="primitive" href="primitive.u32.html">u32</a>>>::<a class="trait" href="../std/convert/trait.TryFrom.html" title="trait std::convert::TryFrom">Error</a>></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>try_from </code><a href="https://github.com/rust-lang/rust/issues/33417">#33417</a>)</div></div><div class='docblock'><p>Performs the conversion.</p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/hash/trait.Hash.html" title="trait std::hash::Hash">Hash</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/core/hash/mod.rs.html#538-542' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='method.hash' class="method"><span id='hash.v' class='invisible'><code>fn <a href='../std/hash/trait.Hash.html#tymethod.hash' class='fnname'>hash</a><H>(&self, state: &mut H) <span class="where fmt-newline">where<br> H: <a class="trait" href="../std/hash/trait.Hasher.html" title="trait std::hash::Hasher">Hasher</a>, </span></code></span></h4> <div class='docblock'><p>Feeds this value into the given [<code>Hasher</code>]. <a href="../std/hash/trait.Hash.html#tymethod.hash">Read more</a></p> </div><h4 id='method.hash_slice' class="method"><span id='hash_slice.v' class='invisible'><code>fn <a href='../std/hash/trait.Hash.html#method.hash_slice' class='fnname'>hash_slice</a><H>(data: <a class="primitive" href="primitive.slice.html">&[Self]</a>, state: &mut H) <span class="where fmt-newline">where<br> H: <a class="trait" href="../std/hash/trait.Hasher.html" title="trait std::hash::Hasher">Hasher</a>, </span></code><div class='since' title='Stable since Rust version 1.3.0'>1.3.0</div></span></h4> <div class='docblock'><p>Feeds a slice of this type into the given [<code>Hasher</code>]. <a href="../std/hash/trait.Hash.html#method.hash_slice">Read more</a></p> </div></div><h3 class='impl'><span class='in-band'><code>impl <a class="trait" href="../std/ascii/trait.AsciiExt.html" title="trait std::ascii::AsciiExt">AsciiExt</a> for <a class="primitive" href="primitive.char.html">char</a></code></span><span class='out-of-band'><div class='ghost'></div><a class='srclink' href='../src/std/ascii.rs.html#864-948' title='goto source code'>[src]</a></span></h3> <div class='impl-items'><h4 id='associatedtype.Owned' class="type"><span id='Owned.t' class='invisible'><code>type <a href='../std/ascii/trait.AsciiExt.html#associatedtype.Owned' class="type">Owned</a> = <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Container type for copied ASCII characters.</p> </div><h4 id='method.is_ascii' class="method"><span id='is_ascii.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.is_ascii' class='fnname'>is_ascii</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Checks if the value is within the ASCII range. <a href="../std/ascii/trait.AsciiExt.html#tymethod.is_ascii">Read more</a></p> </div><h4 id='method.to_ascii_uppercase' class="method"><span id='to_ascii_uppercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.to_ascii_uppercase' class='fnname'>to_ascii_uppercase</a>(&self) -> <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Makes a copy of the value in its ASCII upper case equivalent. <a href="../std/ascii/trait.AsciiExt.html#tymethod.to_ascii_uppercase">Read more</a></p> </div><h4 id='method.to_ascii_lowercase' class="method"><span id='to_ascii_lowercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.to_ascii_lowercase' class='fnname'>to_ascii_lowercase</a>(&self) -> <a class="primitive" href="primitive.char.html">char</a></code></span></h4> <div class='docblock'><p>Makes a copy of the value in its ASCII lower case equivalent. <a href="../std/ascii/trait.AsciiExt.html#tymethod.to_ascii_lowercase">Read more</a></p> </div><h4 id='method.eq_ignore_ascii_case' class="method"><span id='eq_ignore_ascii_case.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.eq_ignore_ascii_case' class='fnname'>eq_ignore_ascii_case</a>(&self, other: &<a class="primitive" href="primitive.char.html">char</a>) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='docblock'><p>Checks that two values are an ASCII case-insensitive match. <a href="../std/ascii/trait.AsciiExt.html#tymethod.eq_ignore_ascii_case">Read more</a></p> </div><h4 id='method.make_ascii_uppercase' class="method"><span id='make_ascii_uppercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.make_ascii_uppercase' class='fnname'>make_ascii_uppercase</a>(&mut self)</code></span></h4> <div class='docblock'><p>Converts this type to its ASCII upper case equivalent in-place. <a href="../std/ascii/trait.AsciiExt.html#tymethod.make_ascii_uppercase">Read more</a></p> </div><h4 id='method.make_ascii_lowercase' class="method"><span id='make_ascii_lowercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#tymethod.make_ascii_lowercase' class='fnname'>make_ascii_lowercase</a>(&mut self)</code></span></h4> <div class='docblock'><p>Converts this type to its ASCII lower case equivalent in-place. <a href="../std/ascii/trait.AsciiExt.html#tymethod.make_ascii_lowercase">Read more</a></p> </div><h4 id='method.is_ascii_alphabetic' class="method"><span id='is_ascii_alphabetic.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_alphabetic' class='fnname'>is_ascii_alphabetic</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII alphabetic character: U+0041 'A' ... U+005A 'Z' or U+0061 'a' ... U+007A 'z'. For strings, true if all characters in the string are ASCII alphabetic. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_alphabetic">Read more</a></p> </div><h4 id='method.is_ascii_uppercase' class="method"><span id='is_ascii_uppercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_uppercase' class='fnname'>is_ascii_uppercase</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII uppercase character: U+0041 'A' ... U+005A 'Z'. For strings, true if all characters in the string are ASCII uppercase. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_uppercase">Read more</a></p> </div><h4 id='method.is_ascii_lowercase' class="method"><span id='is_ascii_lowercase.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_lowercase' class='fnname'>is_ascii_lowercase</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII lowercase character: U+0061 'a' ... U+007A 'z'. For strings, true if all characters in the string are ASCII lowercase. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_lowercase">Read more</a></p> </div><h4 id='method.is_ascii_alphanumeric' class="method"><span id='is_ascii_alphanumeric.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_alphanumeric' class='fnname'>is_ascii_alphanumeric</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII alphanumeric character: U+0041 'A' ... U+005A 'Z', U+0061 'a' ... U+007A 'z', or U+0030 '0' ... U+0039 '9'. For strings, true if all characters in the string are ASCII alphanumeric. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_alphanumeric">Read more</a></p> </div><h4 id='method.is_ascii_digit' class="method"><span id='is_ascii_digit.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_digit' class='fnname'>is_ascii_digit</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII decimal digit: U+0030 '0' ... U+0039 '9'. For strings, true if all characters in the string are ASCII digits. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_digit">Read more</a></p> </div><h4 id='method.is_ascii_hexdigit' class="method"><span id='is_ascii_hexdigit.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_hexdigit' class='fnname'>is_ascii_hexdigit</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII hexadecimal digit: U+0030 '0' ... U+0039 '9', U+0041 'A' ... U+0046 'F', or U+0061 'a' ... U+0066 'f'. For strings, true if all characters in the string are ASCII hex digits. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_hexdigit">Read more</a></p> </div><h4 id='method.is_ascii_punctuation' class="method"><span id='is_ascii_punctuation.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_punctuation' class='fnname'>is_ascii_punctuation</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII punctuation character: U+0021 ... U+002F <code>! " # $ % & ' ( ) * + , - . /</code> U+003A ... U+0040 <code>: ; < = > ? @</code> U+005B ... U+0060 <code>[ \\ ] ^ _ \</code><code>U+007B ... U+007E</code>{ | } ~` For strings, true if all characters in the string are ASCII punctuation. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_punctuation">Read more</a></p> </div><h4 id='method.is_ascii_graphic' class="method"><span id='is_ascii_graphic.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_graphic' class='fnname'>is_ascii_graphic</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII graphic character: U+0021 '@' ... U+007E '~'. For strings, true if all characters in the string are ASCII punctuation. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_graphic">Read more</a></p> </div><h4 id='method.is_ascii_whitespace' class="method"><span id='is_ascii_whitespace.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_whitespace' class='fnname'>is_ascii_whitespace</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII whitespace character: U+0020 SPACE, U+0009 HORIZONTAL TAB, U+000A LINE FEED, U+000C FORM FEED, or U+000D CARRIAGE RETURN. For strings, true if all characters in the string are ASCII whitespace. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_whitespace">Read more</a></p> </div><h4 id='method.is_ascii_control' class="method"><span id='is_ascii_control.v' class='invisible'><code>fn <a href='../std/ascii/trait.AsciiExt.html#method.is_ascii_control' class='fnname'>is_ascii_control</a>(&self) -> <a class="primitive" href="primitive.bool.html">bool</a></code></span></h4> <div class='stability'><div class='stab unstable'><span class=microscope>🔬</span> This is a nightly-only experimental API. (<code>ascii_ctype </code><a href="https://github.com/rust-lang/rust/issues/39658">#39658</a>)</div></div><div class='docblock'><p>Checks if the value is an ASCII control character: U+0000 NUL ... U+001F UNIT SEPARATOR, or U+007F DELETE. Note that most ASCII whitespace characters are control characters, but SPACE is not. <a href="../std/ascii/trait.AsciiExt.html#method.is_ascii_control">Read more</a></p> </div></div></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 = "std"; </script> <script src="../main.js"></script> <script defer src="../search-index.js"></script> </body> </html>