<!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="An owned, immutable wrapper around a `PathBuf` containing the canonical path of an executable."><title>CanonicalPath in which - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-46f98efaafac5295.ttf.woff2,FiraSans-Regular-018c141bf0843ffd.woff2,FiraSans-Medium-8f9a781e4970d388.woff2,SourceCodePro-Regular-562dcc5011b6de7d.ttf.woff2,SourceCodePro-Semibold-d899c5a5c4aeb14a.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2" crossorigin href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-76eba96aa4d2e634.css"><link rel="stylesheet" href="../static.files/rustdoc-dd39b87e5fcfba68.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="which" data-themes="" data-resource-suffix="" data-rustdoc-version="1.81.0-nightly (4bc39f028 2024-06-26)" data-channel="nightly" data-search-js="search-0fe7219eb170c82e.js" data-settings-js="settings-4313503d2e1961c2.js" ><script src="../static.files/storage-118b08c4c78b968e.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-20a3ad099b048cf2.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-df360f571f6edeae.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-422f7d1d52889060.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-2c020d218678b618.svg"></head><body class="rustdoc struct"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><nav class="mobile-topbar"><button class="sidebar-menu-toggle" title="show sidebar"></button></nav><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../which/index.html">which</a><span class="version">6.0.1</span></h2></div><h2 class="location"><a href="#">CanonicalPath</a></h2><div class="sidebar-elems"><section><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.all">all</a></li><li><a href="#method.all_in">all_in</a></li><li><a href="#method.as_path">as_path</a></li><li><a href="#method.into_path_buf">into_path_buf</a></li><li><a href="#method.new">new</a></li><li><a href="#method.new_in">new_in</a></li></ul><h3><a href="#deref-methods-Path">Methods from Deref<Target=Path></a></h3><ul class="block deref-methods"><li><a href="#method.ancestors">ancestors</a></li><li><a href="#method.as_os_str">as_os_str</a></li><li><a href="#method.canonicalize">canonicalize</a></li><li><a href="#method.components">components</a></li><li><a href="#method.display">display</a></li><li><a href="#method.ends_with">ends_with</a></li><li><a href="#method.exists">exists</a></li><li><a href="#method.extension">extension</a></li><li><a href="#method.file_name">file_name</a></li><li><a href="#method.file_prefix">file_prefix</a></li><li><a href="#method.file_stem">file_stem</a></li><li><a href="#method.has_root">has_root</a></li><li><a href="#method.is_absolute">is_absolute</a></li><li><a href="#method.is_dir">is_dir</a></li><li><a href="#method.is_file">is_file</a></li><li><a href="#method.is_relative">is_relative</a></li><li><a href="#method.is_symlink">is_symlink</a></li><li><a href="#method.iter">iter</a></li><li><a href="#method.join">join</a></li><li><a href="#method.metadata">metadata</a></li><li><a href="#method.parent">parent</a></li><li><a href="#method.read_dir">read_dir</a></li><li><a href="#method.read_link">read_link</a></li><li><a href="#method.starts_with">starts_with</a></li><li><a href="#method.strip_prefix">strip_prefix</a></li><li><a href="#method.symlink_metadata">symlink_metadata</a></li><li><a href="#method.to_path_buf">to_path_buf</a></li><li><a href="#method.to_str">to_str</a></li><li><a href="#method.to_string_lossy">to_string_lossy</a></li><li><a href="#method.try_exists">try_exists</a></li><li><a href="#method.with_extension">with_extension</a></li><li><a href="#method.with_file_name">with_file_name</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-AsRef%3COsStr%3E-for-CanonicalPath">AsRef<OsStr></a></li><li><a href="#impl-AsRef%3CPath%3E-for-CanonicalPath">AsRef<Path></a></li><li><a href="#impl-Clone-for-CanonicalPath">Clone</a></li><li><a href="#impl-Debug-for-CanonicalPath">Debug</a></li><li><a href="#impl-Deref-for-CanonicalPath">Deref</a></li><li><a href="#impl-Eq-for-CanonicalPath">Eq</a></li><li><a href="#impl-PartialEq-for-CanonicalPath">PartialEq</a></li><li><a href="#impl-PartialEq%3CCanonicalPath%3E-for-PathBuf">PartialEq<CanonicalPath></a></li><li><a href="#impl-PartialEq%3CPathBuf%3E-for-CanonicalPath">PartialEq<PathBuf></a></li><li><a href="#impl-StructuralPartialEq-for-CanonicalPath">StructuralPartialEq</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-CanonicalPath">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-CanonicalPath">RefUnwindSafe</a></li><li><a href="#impl-Send-for-CanonicalPath">Send</a></li><li><a href="#impl-Sync-for-CanonicalPath">Sync</a></li><li><a href="#impl-Unpin-for-CanonicalPath">Unpin</a></li><li><a href="#impl-UnwindSafe-for-CanonicalPath">UnwindSafe</a></li></ul><h3><a href="#blanket-implementations">Blanket Implementations</a></h3><ul class="block blanket-implementation"><li><a href="#impl-Any-for-T">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T">Borrow<T></a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T">BorrowMut<T></a></li><li><a href="#impl-CloneToUninit-for-T">CloneToUninit</a></li><li><a href="#impl-From%3CT%3E-for-T">From<T></a></li><li><a href="#impl-Into%3CU%3E-for-T">Into<U></a></li><li><a href="#impl-IntoEither-for-T">IntoEither</a></li><li><a href="#impl-ToOwned-for-T">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T">TryFrom<U></a></li><li><a href="#impl-TryInto%3CU%3E-for-T">TryInto<U></a></li></ul></section><h2><a href="index.html">In crate which</a></h2></div></nav><div class="sidebar-resizer"></div><main><div class="width-limiter"><rustdoc-search></rustdoc-search><section id="main-content" class="content"><div class="main-heading"><h1>Struct <a href="index.html">which</a>::<wbr><a class="struct" href="#">CanonicalPath</a><button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><span class="out-of-band"><a class="src" href="../src/which/lib.rs.html#518-520">source</a> · <button id="toggle-all-docs" title="collapse all docs">[<span>−</span>]</button></span></div><pre class="rust item-decl"><code>pub struct CanonicalPath { <span class="comment">/* private fields */</span> }</code></pre><details class="toggle top-doc" open><summary class="hideme"><span>Expand description</span></summary><div class="docblock"><p>An owned, immutable wrapper around a <code>PathBuf</code> containing the <em>canonical</em> path of an
executable.</p>
<p>The constructed <code>PathBuf</code> is the result of <code>which</code> or <code>which_in</code> followed by
<code>Path::canonicalize</code>, but <code>CanonicalPath</code> has the advantage of being a type distinct from
<code>std::path::Path</code> and <code>std::path::PathBuf</code>.</p>
<p>It can be beneficial to use <code>CanonicalPath</code> instead of <code>std::path::Path</code> when you want the type
system to enforce the need for a path that exists, points to a binary that is executable, is
absolute, has all components normalized, and has all symbolic links resolved</p>
<p>Since <code>CanonicalPath</code> implements <code>Deref</code> for <code>std::path::Path</code>, all methods on
<code>&std::path::Path</code> are also available to <code>&CanonicalPath</code> values.</p>
</div></details><h2 id="implementations" class="section-header">Implementations<a href="#implementations" class="anchor">§</a></h2><div id="implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#522-596">source</a><a href="#impl-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new" class="method"><a class="src rightside" href="../src/which/lib.rs.html#526-530">source</a><h4 class="code-header">pub fn <a href="#method.new" class="fn">new</a><T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>>(binary_name: T) -> <a class="type" href="type.Result.html" title="type which::Result">Result</a><<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>></h4></section></summary><div class="docblock"><p>Returns the canonical path of an executable binary by name.</p>
<p>This calls <code>which</code> and <code>Path::canonicalize</code> and maps the result into a <code>CanonicalPath</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.all" class="method"><a class="src rightside" href="../src/which/lib.rs.html#535-546">source</a><h4 class="code-header">pub fn <a href="#method.all" class="fn">all</a><T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>>(
binary_name: T,
) -> <a class="type" href="type.Result.html" title="type which::Result">Result</a><impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = <a class="type" href="type.Result.html" title="type which::Result">Result</a><<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>>>></h4></section></summary><div class="docblock"><p>Returns the canonical paths of an executable binary by name.</p>
<p>This calls <code>which_all</code> and <code>Path::canonicalize</code> and maps the results into <code>CanonicalPath</code>s.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.new_in" class="method"><a class="src rightside" href="../src/which/lib.rs.html#552-561">source</a><h4 class="code-header">pub fn <a href="#method.new_in" class="fn">new_in</a><T, U, V>(
binary_name: T,
paths: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><U>,
cwd: V,
) -> <a class="type" href="type.Result.html" title="type which::Result">Result</a><<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>><div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,
V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Returns the canonical path of an executable binary by name in the path list <code>paths</code> and
using the current working directory <code>cwd</code> to resolve relative paths.</p>
<p>This calls <code>which_in</code> and <code>Path::canonicalize</code> and maps the result into a <code>CanonicalPath</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.all_in" class="method"><a class="src rightside" href="../src/which/lib.rs.html#567-585">source</a><h4 class="code-header">pub fn <a href="#method.all_in" class="fn">all_in</a><T, U, V>(
binary_name: T,
paths: <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><U>,
cwd: V,
) -> <a class="type" href="type.Result.html" title="type which::Result">Result</a><impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/iter/traits/iterator/trait.Iterator.html" title="trait core::iter::traits::iterator::Iterator">Iterator</a><Item = <a class="type" href="type.Result.html" title="type which::Result">Result</a><<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>>>><div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,
V: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Returns all of the canonical paths of an executable binary by name in the path list <code>paths</code> and
using the current working directory <code>cwd</code> to resolve relative paths.</p>
<p>This calls <code>which_in_all</code> and <code>Path::canonicalize</code> and maps the result into a <code>CanonicalPath</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.as_path" class="method"><a class="src rightside" href="../src/which/lib.rs.html#588-590">source</a><h4 class="code-header">pub fn <a href="#method.as_path" class="fn">as_path</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></h4></section></summary><div class="docblock"><p>Returns a reference to a <code>std::path::Path</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_path_buf" class="method"><a class="src rightside" href="../src/which/lib.rs.html#593-595">source</a><h4 class="code-header">pub fn <a href="#method.into_path_buf" class="fn">into_path_buf</a>(self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a></h4></section></summary><div class="docblock"><p>Consumes the <code>which::CanonicalPath</code>, yielding its underlying <code>std::path::PathBuf</code>.</p>
</div></details></div></details></div><h2 id="deref-methods-Path" class="section-header"><span>Methods from <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a><Target = <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>></span><a href="#deref-methods-Path" class="anchor">§</a></h2><div id="deref-methods-Path-1" class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_os_str" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2089">source</a></span><h4 class="code-header">pub fn <a href="#method.as_os_str" class="fn">as_os_str</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a></h4></section></summary><div class="docblock"><p>Yields the underlying <a href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr"><code>OsStr</code></a> slice.</p>
<h5 id="examples"><a class="doc-anchor" href="#examples">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>os_str = Path::new(<span class="string">"foo.txt"</span>).as_os_str();
<span class="macro">assert_eq!</span>(os_str, std::ffi::OsStr::new(<span class="string">"foo.txt"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_str" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2134">source</a></span><h4 class="code-header">pub fn <a href="#method.to_str" class="fn">to_str</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Yields a <a href="https://doc.rust-lang.org/nightly/std/primitive.str.html" title="primitive str"><code>&str</code></a> slice if the <code>Path</code> is valid unicode.</p>
<p>This conversion may entail doing a check for UTF-8 validity.
Note that validation is performed because non-UTF-8 strings are
perfectly valid for some OS.</p>
<h5 id="examples-1"><a class="doc-anchor" href="#examples-1">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"foo.txt"</span>);
<span class="macro">assert_eq!</span>(path.to_str(), <span class="prelude-val">Some</span>(<span class="string">"foo.txt"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_string_lossy" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2162">source</a></span><h4 class="code-header">pub fn <a href="#method.to_string_lossy" class="fn">to_string_lossy</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow">Cow</a><'_, <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.str.html">str</a>></h4></section></summary><div class="docblock"><p>Converts a <code>Path</code> to a <a href="https://doc.rust-lang.org/nightly/alloc/borrow/enum.Cow.html" title="enum alloc::borrow::Cow"><code>Cow<str></code></a>.</p>
<p>Any non-Unicode sequences are replaced with
<a href="https://doc.rust-lang.org/nightly/core/char/constant.REPLACEMENT_CHARACTER.html" title="constant core::char::REPLACEMENT_CHARACTER"><code>U+FFFD REPLACEMENT CHARACTER</code></a>.</p>
<h5 id="examples-2"><a class="doc-anchor" href="#examples-2">§</a>Examples</h5>
<p>Calling <code>to_string_lossy</code> on a <code>Path</code> with valid unicode:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"foo.txt"</span>);
<span class="macro">assert_eq!</span>(path.to_string_lossy(), <span class="string">"foo.txt"</span>);</code></pre></div>
<p>Had <code>path</code> contained invalid unicode, the <code>to_string_lossy</code> call might
have returned <code>"fo�.txt"</code>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.to_path_buf" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2180">source</a></span><h4 class="code-header">pub fn <a href="#method.to_path_buf" class="fn">to_path_buf</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a></h4></section></summary><div class="docblock"><p>Converts a <code>Path</code> to an owned <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf"><code>PathBuf</code></a>.</p>
<h5 id="examples-3"><a class="doc-anchor" href="#examples-3">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">let </span>path_buf = Path::new(<span class="string">"foo.txt"</span>).to_path_buf();
<span class="macro">assert_eq!</span>(path_buf, PathBuf::from(<span class="string">"foo.txt"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_absolute" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2205">source</a></span><h4 class="code-header">pub fn <a href="#method.is_absolute" class="fn">is_absolute</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the <code>Path</code> is absolute, i.e., if it is independent of
the current directory.</p>
<ul>
<li>
<p>On Unix, a path is absolute if it starts with the root, so
<code>is_absolute</code> and <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.has_root" title="method std::path::Path::has_root"><code>has_root</code></a> are equivalent.</p>
</li>
<li>
<p>On Windows, a path is absolute if it has a prefix and starts with the
root: <code>c:\windows</code> is absolute, while <code>c:temp</code> and <code>\temp</code> are not.</p>
</li>
</ul>
<h5 id="examples-4"><a class="doc-anchor" href="#examples-4">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert!</span>(!Path::new(<span class="string">"foo.txt"</span>).is_absolute());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_relative" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2230">source</a></span><h4 class="code-header">pub fn <a href="#method.is_relative" class="fn">is_relative</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the <code>Path</code> is relative, i.e., not absolute.</p>
<p>See <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.is_absolute" title="method std::path::Path::is_absolute"><code>is_absolute</code></a>’s documentation for more details.</p>
<h5 id="examples-5"><a class="doc-anchor" href="#examples-5">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert!</span>(Path::new(<span class="string">"foo.txt"</span>).is_relative());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.has_root" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2257">source</a></span><h4 class="code-header">pub fn <a href="#method.has_root" class="fn">has_root</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the <code>Path</code> has a root.</p>
<ul>
<li>
<p>On Unix, a path has a root if it begins with <code>/</code>.</p>
</li>
<li>
<p>On Windows, a path has a root if it:</p>
<ul>
<li>has no prefix and begins with a separator, e.g., <code>\windows</code></li>
<li>has a prefix followed by a separator, e.g., <code>c:\windows</code> but not <code>c:windows</code></li>
<li>has any non-disk prefix, e.g., <code>\\server\share</code></li>
</ul>
</li>
</ul>
<h5 id="examples-6"><a class="doc-anchor" href="#examples-6">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert!</span>(Path::new(<span class="string">"/etc/passwd"</span>).has_root());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.parent" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2292">source</a></span><h4 class="code-header">pub fn <a href="#method.parent" class="fn">parent</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>></h4></section></summary><div class="docblock"><p>Returns the <code>Path</code> without its final component, if there is one.</p>
<p>This means it returns <code>Some("")</code> for relative paths with one component.</p>
<p>Returns <a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> if the path terminates in a root or prefix, or if it’s
the empty string.</p>
<h5 id="examples-7"><a class="doc-anchor" href="#examples-7">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/foo/bar"</span>);
<span class="kw">let </span>parent = path.parent().unwrap();
<span class="macro">assert_eq!</span>(parent, Path::new(<span class="string">"/foo"</span>));
<span class="kw">let </span>grand_parent = parent.parent().unwrap();
<span class="macro">assert_eq!</span>(grand_parent, Path::new(<span class="string">"/"</span>));
<span class="macro">assert_eq!</span>(grand_parent.parent(), <span class="prelude-val">None</span>);
<span class="kw">let </span>relative_path = Path::new(<span class="string">"foo/bar"</span>);
<span class="kw">let </span>parent = relative_path.parent();
<span class="macro">assert_eq!</span>(parent, <span class="prelude-val">Some</span>(Path::new(<span class="string">"foo"</span>)));
<span class="kw">let </span>grand_parent = parent.and_then(Path::parent);
<span class="macro">assert_eq!</span>(grand_parent, <span class="prelude-val">Some</span>(Path::new(<span class="string">""</span>)));
<span class="kw">let </span>great_grand_parent = grand_parent.and_then(Path::parent);
<span class="macro">assert_eq!</span>(great_grand_parent, <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ancestors" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.28.0">1.28.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2332">source</a></span><h4 class="code-header">pub fn <a href="#method.ancestors" class="fn">ancestors</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Ancestors.html" title="struct std::path::Ancestors">Ancestors</a><'_></h4></section></summary><div class="docblock"><p>Produces an iterator over <code>Path</code> and its ancestors.</p>
<p>The iterator will yield the <code>Path</code> that is returned if the <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.parent" title="method std::path::Path::parent"><code>parent</code></a> method is used zero
or more times. If the <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.parent" title="method std::path::Path::parent"><code>parent</code></a> method returns <a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, the iterator will do likewise.
The iterator will always yield at least one value, namely <code>Some(&self)</code>. Next it will yield
<code>&self.parent()</code>, <code>&self.parent().and_then(Path::parent)</code> and so on.</p>
<h5 id="examples-8"><a class="doc-anchor" href="#examples-8">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span><span class="kw-2">mut </span>ancestors = Path::new(<span class="string">"/foo/bar"</span>).ancestors();
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">"/foo/bar"</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">"/foo"</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">"/"</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">None</span>);
<span class="kw">let </span><span class="kw-2">mut </span>ancestors = Path::new(<span class="string">"../foo/bar"</span>).ancestors();
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">"../foo/bar"</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">"../foo"</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">".."</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">Some</span>(Path::new(<span class="string">""</span>)));
<span class="macro">assert_eq!</span>(ancestors.next(), <span class="prelude-val">None</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.file_name" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2359">source</a></span><h4 class="code-header">pub fn <a href="#method.file_name" class="fn">file_name</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></h4></section></summary><div class="docblock"><p>Returns the final component of the <code>Path</code>, if there is one.</p>
<p>If the path is a normal file, this is the file name. If it’s the path of a directory, this
is the directory name.</p>
<p>Returns <a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a> if the path terminates in <code>..</code>.</p>
<h5 id="examples-9"><a class="doc-anchor" href="#examples-9">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">use </span>std::ffi::OsStr;
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(OsStr::new(<span class="string">"bin"</span>)), Path::new(<span class="string">"/usr/bin/"</span>).file_name());
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(OsStr::new(<span class="string">"foo.txt"</span>)), Path::new(<span class="string">"tmp/foo.txt"</span>).file_name());
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(OsStr::new(<span class="string">"foo.txt"</span>)), Path::new(<span class="string">"foo.txt/."</span>).file_name());
<span class="macro">assert_eq!</span>(<span class="prelude-val">Some</span>(OsStr::new(<span class="string">"foo.txt"</span>)), Path::new(<span class="string">"foo.txt/.//"</span>).file_name());
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, Path::new(<span class="string">"foo.txt/.."</span>).file_name());
<span class="macro">assert_eq!</span>(<span class="prelude-val">None</span>, Path::new(<span class="string">"/"</span>).file_name());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.strip_prefix" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.7.0">1.7.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2395-2397">source</a></span><h4 class="code-header">pub fn <a href="#method.strip_prefix" class="fn">strip_prefix</a><P>(&self, base: P) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.StripPrefixError.html" title="struct std::path::StripPrefixError">StripPrefixError</a>><div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Returns a path that, when joined onto <code>base</code>, yields <code>self</code>.</p>
<h5 id="errors"><a class="doc-anchor" href="#errors">§</a>Errors</h5>
<p>If <code>base</code> is not a prefix of <code>self</code> (i.e., <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.starts_with" title="method std::path::Path::starts_with"><code>starts_with</code></a>
returns <code>false</code>), returns <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Err" title="variant core::result::Result::Err"><code>Err</code></a>.</p>
<h5 id="examples-10"><a class="doc-anchor" href="#examples-10">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">let </span>path = Path::new(<span class="string">"/test/haha/foo.txt"</span>);
<span class="macro">assert_eq!</span>(path.strip_prefix(<span class="string">"/"</span>), <span class="prelude-val">Ok</span>(Path::new(<span class="string">"test/haha/foo.txt"</span>)));
<span class="macro">assert_eq!</span>(path.strip_prefix(<span class="string">"/test"</span>), <span class="prelude-val">Ok</span>(Path::new(<span class="string">"haha/foo.txt"</span>)));
<span class="macro">assert_eq!</span>(path.strip_prefix(<span class="string">"/test/"</span>), <span class="prelude-val">Ok</span>(Path::new(<span class="string">"haha/foo.txt"</span>)));
<span class="macro">assert_eq!</span>(path.strip_prefix(<span class="string">"/test/haha/foo.txt"</span>), <span class="prelude-val">Ok</span>(Path::new(<span class="string">""</span>)));
<span class="macro">assert_eq!</span>(path.strip_prefix(<span class="string">"/test/haha/foo.txt/"</span>), <span class="prelude-val">Ok</span>(Path::new(<span class="string">""</span>)));
<span class="macro">assert!</span>(path.strip_prefix(<span class="string">"test"</span>).is_err());
<span class="macro">assert!</span>(path.strip_prefix(<span class="string">"/haha"</span>).is_err());
<span class="kw">let </span>prefix = PathBuf::from(<span class="string">"/test/"</span>);
<span class="macro">assert_eq!</span>(path.strip_prefix(prefix), <span class="prelude-val">Ok</span>(Path::new(<span class="string">"haha/foo.txt"</span>)));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.starts_with" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2432">source</a></span><h4 class="code-header">pub fn <a href="#method.starts_with" class="fn">starts_with</a><P>(&self, base: P) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a><div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Determines whether <code>base</code> is a prefix of <code>self</code>.</p>
<p>Only considers whole path components to match.</p>
<h5 id="examples-11"><a class="doc-anchor" href="#examples-11">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/etc/passwd"</span>);
<span class="macro">assert!</span>(path.starts_with(<span class="string">"/etc"</span>));
<span class="macro">assert!</span>(path.starts_with(<span class="string">"/etc/"</span>));
<span class="macro">assert!</span>(path.starts_with(<span class="string">"/etc/passwd"</span>));
<span class="macro">assert!</span>(path.starts_with(<span class="string">"/etc/passwd/"</span>)); <span class="comment">// extra slash is okay
</span><span class="macro">assert!</span>(path.starts_with(<span class="string">"/etc/passwd///"</span>)); <span class="comment">// multiple extra slashes are okay
</span><span class="macro">assert!</span>(!path.starts_with(<span class="string">"/e"</span>));
<span class="macro">assert!</span>(!path.starts_with(<span class="string">"/etc/passwd.txt"</span>));
<span class="macro">assert!</span>(!Path::new(<span class="string">"/etc/foo.rs"</span>).starts_with(<span class="string">"/etc/foo"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.ends_with" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2460">source</a></span><h4 class="code-header">pub fn <a href="#method.ends_with" class="fn">ends_with</a><P>(&self, child: P) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a><div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Determines whether <code>child</code> is a suffix of <code>self</code>.</p>
<p>Only considers whole path components to match.</p>
<h5 id="examples-12"><a class="doc-anchor" href="#examples-12">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/etc/resolv.conf"</span>);
<span class="macro">assert!</span>(path.ends_with(<span class="string">"resolv.conf"</span>));
<span class="macro">assert!</span>(path.ends_with(<span class="string">"etc/resolv.conf"</span>));
<span class="macro">assert!</span>(path.ends_with(<span class="string">"/etc/resolv.conf"</span>));
<span class="macro">assert!</span>(!path.ends_with(<span class="string">"/resolv.conf"</span>));
<span class="macro">assert!</span>(!path.ends_with(<span class="string">"conf"</span>)); <span class="comment">// use .extension() instead</span></code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.file_stem" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2496">source</a></span><h4 class="code-header">pub fn <a href="#method.file_stem" class="fn">file_stem</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></h4></section></summary><div class="docblock"><p>Extracts the stem (non-extension) portion of <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.file_name" title="method std::path::Path::file_name"><code>self.file_name</code></a>.</p>
<p>The stem is:</p>
<ul>
<li><a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, if there is no file name;</li>
<li>The entire file name if there is no embedded <code>.</code>;</li>
<li>The entire file name if the file name begins with <code>.</code> and has no other <code>.</code>s within;</li>
<li>Otherwise, the portion of the file name before the final <code>.</code></li>
</ul>
<h5 id="examples-13"><a class="doc-anchor" href="#examples-13">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert_eq!</span>(<span class="string">"foo"</span>, Path::new(<span class="string">"foo.rs"</span>).file_stem().unwrap());
<span class="macro">assert_eq!</span>(<span class="string">"foo.tar"</span>, Path::new(<span class="string">"foo.tar.gz"</span>).file_stem().unwrap());</code></pre></div>
<h5 id="see-also"><a class="doc-anchor" href="#see-also">§</a>See Also</h5>
<p>This method is similar to <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.file_prefix" title="method std::path::Path::file_prefix"><code>Path::file_prefix</code></a>, which extracts the portion of the file name
before the <em>first</em> <code>.</code></p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.file_prefix" class="method"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2530">source</a><h4 class="code-header">pub fn <a href="#method.file_prefix" class="fn">file_prefix</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></h4></section><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>path_file_prefix</code>)</span></div></span></summary><div class="docblock"><p>Extracts the prefix of <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.file_name" title="method std::path::Path::file_name"><code>self.file_name</code></a>.</p>
<p>The prefix is:</p>
<ul>
<li><a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, if there is no file name;</li>
<li>The entire file name if there is no embedded <code>.</code>;</li>
<li>The portion of the file name before the first non-beginning <code>.</code>;</li>
<li>The entire file name if the file name begins with <code>.</code> and has no other <code>.</code>s within;</li>
<li>The portion of the file name before the second <code>.</code> if the file name begins with <code>.</code></li>
</ul>
<h5 id="examples-14"><a class="doc-anchor" href="#examples-14">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert_eq!</span>(<span class="string">"foo"</span>, Path::new(<span class="string">"foo.rs"</span>).file_prefix().unwrap());
<span class="macro">assert_eq!</span>(<span class="string">"foo"</span>, Path::new(<span class="string">"foo.tar.gz"</span>).file_prefix().unwrap());</code></pre></div>
<h5 id="see-also-1"><a class="doc-anchor" href="#see-also-1">§</a>See Also</h5>
<p>This method is similar to <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.file_stem" title="method std::path::Path::file_stem"><code>Path::file_stem</code></a>, which extracts the portion of the file name
before the <em>last</em> <code>.</code></p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.extension" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2555">source</a></span><h4 class="code-header">pub fn <a href="#method.extension" class="fn">extension</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html" title="enum core::option::Option">Option</a><&<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>></h4></section></summary><div class="docblock"><p>Extracts the extension (without the leading dot) of <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.file_name" title="method std::path::Path::file_name"><code>self.file_name</code></a>, if possible.</p>
<p>The extension is:</p>
<ul>
<li><a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, if there is no file name;</li>
<li><a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, if there is no embedded <code>.</code>;</li>
<li><a href="https://doc.rust-lang.org/nightly/core/option/enum.Option.html#variant.None" title="variant core::option::Option::None"><code>None</code></a>, if the file name begins with <code>.</code> and has no other <code>.</code>s within;</li>
<li>Otherwise, the portion of the file name after the final <code>.</code></li>
</ul>
<h5 id="examples-15"><a class="doc-anchor" href="#examples-15">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert_eq!</span>(<span class="string">"rs"</span>, Path::new(<span class="string">"foo.rs"</span>).extension().unwrap());
<span class="macro">assert_eq!</span>(<span class="string">"gz"</span>, Path::new(<span class="string">"foo.tar.gz"</span>).extension().unwrap());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.join" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2575">source</a></span><h4 class="code-header">pub fn <a href="#method.join" class="fn">join</a><P>(&self, path: P) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a><div class="where">where
P: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>>,</div></h4></section></summary><div class="docblock"><p>Creates an owned <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf"><code>PathBuf</code></a> with <code>path</code> adjoined to <code>self</code>.</p>
<p>If <code>path</code> is absolute, it replaces the current path.</p>
<p>See <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html#method.push" title="method std::path::PathBuf::push"><code>PathBuf::push</code></a> for more details on what it means to adjoin a path.</p>
<h5 id="examples-16"><a class="doc-anchor" href="#examples-16">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"/etc"</span>).join(<span class="string">"passwd"</span>), PathBuf::from(<span class="string">"/etc/passwd"</span>));
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"/etc"</span>).join(<span class="string">"/bin/sh"</span>), PathBuf::from(<span class="string">"/bin/sh"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_file_name" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2603">source</a></span><h4 class="code-header">pub fn <a href="#method.with_file_name" class="fn">with_file_name</a><S>(&self, file_name: S) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a><div class="where">where
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,</div></h4></section></summary><div class="docblock"><p>Creates an owned <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf"><code>PathBuf</code></a> like <code>self</code> but with the given file name.</p>
<p>See <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html#method.set_file_name" title="method std::path::PathBuf::set_file_name"><code>PathBuf::set_file_name</code></a> for more details.</p>
<h5 id="examples-17"><a class="doc-anchor" href="#examples-17">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">let </span>path = Path::new(<span class="string">"/tmp/foo.png"</span>);
<span class="macro">assert_eq!</span>(path.with_file_name(<span class="string">"bar"</span>), PathBuf::from(<span class="string">"/tmp/bar"</span>));
<span class="macro">assert_eq!</span>(path.with_file_name(<span class="string">"bar.txt"</span>), PathBuf::from(<span class="string">"/tmp/bar.txt"</span>));
<span class="kw">let </span>path = Path::new(<span class="string">"/tmp"</span>);
<span class="macro">assert_eq!</span>(path.with_file_name(<span class="string">"var"</span>), PathBuf::from(<span class="string">"/var"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_extension" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2631">source</a></span><h4 class="code-header">pub fn <a href="#method.with_extension" class="fn">with_extension</a><S>(&self, extension: S) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a><div class="where">where
S: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>>,</div></h4></section></summary><div class="docblock"><p>Creates an owned <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf"><code>PathBuf</code></a> like <code>self</code> but with the given extension.</p>
<p>See <a href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html#method.set_extension" title="method std::path::PathBuf::set_extension"><code>PathBuf::set_extension</code></a> for more details.</p>
<h5 id="examples-18"><a class="doc-anchor" href="#examples-18">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">let </span>path = Path::new(<span class="string">"foo.rs"</span>);
<span class="macro">assert_eq!</span>(path.with_extension(<span class="string">"txt"</span>), PathBuf::from(<span class="string">"foo.txt"</span>));
<span class="kw">let </span>path = Path::new(<span class="string">"foo.tar.gz"</span>);
<span class="macro">assert_eq!</span>(path.with_extension(<span class="string">""</span>), PathBuf::from(<span class="string">"foo.tar"</span>));
<span class="macro">assert_eq!</span>(path.with_extension(<span class="string">"xz"</span>), PathBuf::from(<span class="string">"foo.tar.xz"</span>));
<span class="macro">assert_eq!</span>(path.with_extension(<span class="string">""</span>).with_extension(<span class="string">"txt"</span>), PathBuf::from(<span class="string">"foo.txt"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.components" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2693">source</a></span><h4 class="code-header">pub fn <a href="#method.components" class="fn">components</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Components.html" title="struct std::path::Components">Components</a><'_></h4></section></summary><div class="docblock"><p>Produces an iterator over the <a href="https://doc.rust-lang.org/nightly/std/path/enum.Component.html" title="enum std::path::Component"><code>Component</code></a>s of the path.</p>
<p>When parsing the path, there is a small amount of normalization:</p>
<ul>
<li>
<p>Repeated separators are ignored, so <code>a/b</code> and <code>a//b</code> both have
<code>a</code> and <code>b</code> as components.</p>
</li>
<li>
<p>Occurrences of <code>.</code> are normalized away, except if they are at the
beginning of the path. For example, <code>a/./b</code>, <code>a/b/</code>, <code>a/b/.</code> and
<code>a/b</code> all have <code>a</code> and <code>b</code> as components, but <code>./a/b</code> starts with
an additional <a href="https://doc.rust-lang.org/nightly/std/path/enum.Component.html#variant.CurDir" title="variant std::path::Component::CurDir"><code>CurDir</code></a> component.</p>
</li>
<li>
<p>A trailing slash is normalized away, <code>/a/b</code> and <code>/a/b/</code> are equivalent.</p>
</li>
</ul>
<p>Note that no other normalization takes place; in particular, <code>a/c</code>
and <code>a/b/../c</code> are distinct, to account for the possibility that <code>b</code>
is a symbolic link (so its parent isn’t <code>a</code>).</p>
<h5 id="examples-19"><a class="doc-anchor" href="#examples-19">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, Component};
<span class="kw">use </span>std::ffi::OsStr;
<span class="kw">let </span><span class="kw-2">mut </span>components = Path::new(<span class="string">"/tmp/foo.txt"</span>).components();
<span class="macro">assert_eq!</span>(components.next(), <span class="prelude-val">Some</span>(Component::RootDir));
<span class="macro">assert_eq!</span>(components.next(), <span class="prelude-val">Some</span>(Component::Normal(OsStr::new(<span class="string">"tmp"</span>))));
<span class="macro">assert_eq!</span>(components.next(), <span class="prelude-val">Some</span>(Component::Normal(OsStr::new(<span class="string">"foo.txt"</span>))));
<span class="macro">assert_eq!</span>(components.next(), <span class="prelude-val">None</span>)</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.iter" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2727">source</a></span><h4 class="code-header">pub fn <a href="#method.iter" class="fn">iter</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Iter.html" title="struct std::path::Iter">Iter</a><'_></h4></section></summary><div class="docblock"><p>Produces an iterator over the path’s components viewed as <a href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr"><code>OsStr</code></a>
slices.</p>
<p>For more information about the particulars of how the path is separated
into components, see <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.components" title="method std::path::Path::components"><code>components</code></a>.</p>
<h5 id="examples-20"><a class="doc-anchor" href="#examples-20">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{<span class="self">self</span>, Path};
<span class="kw">use </span>std::ffi::OsStr;
<span class="kw">let </span><span class="kw-2">mut </span>it = Path::new(<span class="string">"/tmp/foo.txt"</span>).iter();
<span class="macro">assert_eq!</span>(it.next(), <span class="prelude-val">Some</span>(OsStr::new(<span class="kw-2">&</span>path::MAIN_SEPARATOR.to_string())));
<span class="macro">assert_eq!</span>(it.next(), <span class="prelude-val">Some</span>(OsStr::new(<span class="string">"tmp"</span>)));
<span class="macro">assert_eq!</span>(it.next(), <span class="prelude-val">Some</span>(OsStr::new(<span class="string">"foo.txt"</span>)));
<span class="macro">assert_eq!</span>(it.next(), <span class="prelude-val">None</span>)</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.display" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2752">source</a></span><h4 class="code-header">pub fn <a href="#method.display" class="fn">display</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Display.html" title="struct std::path::Display">Display</a><'_></h4></section></summary><div class="docblock"><p>Returns an object that implements <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Display.html" title="trait core::fmt::Display"><code>Display</code></a> for safely printing paths
that may contain non-Unicode data. This may perform lossy conversion,
depending on the platform. If you would like an implementation which
escapes the path please use <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug"><code>Debug</code></a> instead.</p>
<h5 id="examples-21"><a class="doc-anchor" href="#examples-21">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/tmp/foo.rs"</span>);
<span class="macro">println!</span>(<span class="string">"{}"</span>, path.display());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.metadata" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2774">source</a></span><h4 class="code-header">pub fn <a href="#method.metadata" class="fn">metadata</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Queries the file system to get information about a file, directory, etc.</p>
<p>This function will traverse symbolic links to query information about the
destination file.</p>
<p>This is an alias to <a href="https://doc.rust-lang.org/nightly/std/fs/fn.metadata.html" title="fn std::fs::metadata"><code>fs::metadata</code></a>.</p>
<h5 id="examples-22"><a class="doc-anchor" href="#examples-22">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/Minas/tirith"</span>);
<span class="kw">let </span>metadata = path.metadata().expect(<span class="string">"metadata call failed"</span>);
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, metadata.file_type());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.symlink_metadata" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2793">source</a></span><h4 class="code-header">pub fn <a href="#method.symlink_metadata" class="fn">symlink_metadata</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html" title="struct std::fs::Metadata">Metadata</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Queries the metadata about a file without following symlinks.</p>
<p>This is an alias to <a href="https://doc.rust-lang.org/nightly/std/fs/fn.symlink_metadata.html" title="fn std::fs::symlink_metadata"><code>fs::symlink_metadata</code></a>.</p>
<h5 id="examples-23"><a class="doc-anchor" href="#examples-23">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/Minas/tirith"</span>);
<span class="kw">let </span>metadata = path.symlink_metadata().expect(<span class="string">"symlink_metadata call failed"</span>);
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, metadata.file_type());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.canonicalize" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2812">source</a></span><h4 class="code-header">pub fn <a href="#method.canonicalize" class="fn">canonicalize</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Returns the canonical, absolute form of the path with all intermediate
components normalized and symbolic links resolved.</p>
<p>This is an alias to <a href="https://doc.rust-lang.org/nightly/std/fs/fn.canonicalize.html" title="fn std::fs::canonicalize"><code>fs::canonicalize</code></a>.</p>
<h5 id="examples-24"><a class="doc-anchor" href="#examples-24">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::{Path, PathBuf};
<span class="kw">let </span>path = Path::new(<span class="string">"/foo/test/../test/bar.rs"</span>);
<span class="macro">assert_eq!</span>(path.canonicalize().unwrap(), PathBuf::from(<span class="string">"/foo/test/bar.rs"</span>));</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_link" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2830">source</a></span><h4 class="code-header">pub fn <a href="#method.read_link" class="fn">read_link</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Reads a symbolic link, returning the file that the link points to.</p>
<p>This is an alias to <a href="https://doc.rust-lang.org/nightly/std/fs/fn.read_link.html" title="fn std::fs::read_link"><code>fs::read_link</code></a>.</p>
<h5 id="examples-25"><a class="doc-anchor" href="#examples-25">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/laputa/sky_castle.rs"</span>);
<span class="kw">let </span>path_link = path.read_link().expect(<span class="string">"read_link call failed"</span>);</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.read_dir" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2855">source</a></span><h4 class="code-header">pub fn <a href="#method.read_dir" class="fn">read_dir</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/fs/struct.ReadDir.html" title="struct std::fs::ReadDir">ReadDir</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Returns an iterator over the entries within a directory.</p>
<p>The iterator will yield instances of <code><a href="https://doc.rust-lang.org/nightly/std/io/error/type.Result.html" title="type std::io::error::Result">io::Result</a><<a href="https://doc.rust-lang.org/nightly/std/fs/struct.DirEntry.html" title="struct std::fs::DirEntry">fs::DirEntry</a>></code>. New
errors may be encountered after an iterator is initially constructed.</p>
<p>This is an alias to <a href="https://doc.rust-lang.org/nightly/std/fs/fn.read_dir.html" title="fn std::fs::read_dir"><code>fs::read_dir</code></a>.</p>
<h5 id="examples-26"><a class="doc-anchor" href="#examples-26">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">let </span>path = Path::new(<span class="string">"/laputa"</span>);
<span class="kw">for </span>entry <span class="kw">in </span>path.read_dir().expect(<span class="string">"read_dir call failed"</span>) {
<span class="kw">if let </span><span class="prelude-val">Ok</span>(entry) = entry {
<span class="macro">println!</span>(<span class="string">"{:?}"</span>, entry.path());
}
}</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.exists" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2886">source</a></span><h4 class="code-header">pub fn <a href="#method.exists" class="fn">exists</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the path points at an existing entity.</p>
<p>Warning: this method may be error-prone, consider using <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.try_exists" title="method std::path::Path::try_exists"><code>try_exists()</code></a> instead!
It also has a risk of introducing time-of-check to time-of-use (TOCTOU) bugs.</p>
<p>This function will traverse symbolic links to query information about the
destination file.</p>
<p>If you cannot access the metadata of the file, e.g. because of a
permission error or broken symbolic links, this will return <code>false</code>.</p>
<h5 id="examples-27"><a class="doc-anchor" href="#examples-27">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert!</span>(!Path::new(<span class="string">"does_not_exist.txt"</span>).exists());</code></pre></div>
<h5 id="see-also-2"><a class="doc-anchor" href="#see-also-2">§</a>See Also</h5>
<p>This is a convenience function that coerces errors to false. If you want to
check errors, call <a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.try_exists" title="method std::path::Path::try_exists"><code>Path::try_exists</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_exists" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.63.0">1.63.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2918">source</a></span><h4 class="code-header">pub fn <a href="#method.try_exists" class="fn">try_exists</a>(&self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>, <a class="struct" href="https://doc.rust-lang.org/nightly/std/io/error/struct.Error.html" title="struct std::io::error::Error">Error</a>></h4></section></summary><div class="docblock"><p>Returns <code>Ok(true)</code> if the path points at an existing entity.</p>
<p>This function will traverse symbolic links to query information about the
destination file. In case of broken symbolic links this will return <code>Ok(false)</code>.</p>
<p><a href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html#method.exists" title="method std::path::Path::exists"><code>Path::exists()</code></a> only checks whether or not a path was both found and readable. By
contrast, <code>try_exists</code> will return <code>Ok(true)</code> or <code>Ok(false)</code>, respectively, if the path
was <em>verified</em> to exist or not exist. If its existence can neither be confirmed nor
denied, it will propagate an <code>Err(_)</code> instead. This can be the case if e.g. listing
permission is denied on one of the parent directories.</p>
<p>Note that while this avoids some pitfalls of the <code>exists()</code> method, it still can not
prevent time-of-check to time-of-use (TOCTOU) bugs. You should only use it in scenarios
where those bugs are not an issue.</p>
<p>This is an alias for <a href="https://doc.rust-lang.org/nightly/std/fs/fn.exists.html" title="fn std::fs::exists"><code>std::fs::exists</code></a>.</p>
<h5 id="examples-28"><a class="doc-anchor" href="#examples-28">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert!</span>(!Path::new(<span class="string">"does_not_exist.txt"</span>).try_exists().expect(<span class="string">"Can't check existence of file does_not_exist.txt"</span>));
<span class="macro">assert!</span>(Path::new(<span class="string">"/root/secret_file.txt"</span>).try_exists().is_err());</code></pre></div>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_file" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2951">source</a></span><h4 class="code-header">pub fn <a href="#method.is_file" class="fn">is_file</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the path exists on disk and is pointing at a regular file.</p>
<p>This function will traverse symbolic links to query information about the
destination file.</p>
<p>If you cannot access the metadata of the file, e.g. because of a
permission error or broken symbolic links, this will return <code>false</code>.</p>
<h5 id="examples-29"><a class="doc-anchor" href="#examples-29">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"./is_a_directory/"</span>).is_file(), <span class="bool-val">false</span>);
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"a_file.txt"</span>).is_file(), <span class="bool-val">true</span>);</code></pre></div>
<h5 id="see-also-3"><a class="doc-anchor" href="#see-also-3">§</a>See Also</h5>
<p>This is a convenience function that coerces errors to false. If you want to
check errors, call <a href="https://doc.rust-lang.org/nightly/std/fs/fn.metadata.html" title="fn std::fs::metadata"><code>fs::metadata</code></a> and handle its <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a>. Then call
<a href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html#method.is_file" title="method std::fs::Metadata::is_file"><code>fs::Metadata::is_file</code></a> if it was <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>.</p>
<p>When the goal is simply to read from (or write to) the source, the most
reliable way to test the source can be read (or written to) is to open
it. Only using <code>is_file</code> can break workflows like <code>diff <( prog_a )</code> on
a Unix-like system for example. See <a href="https://doc.rust-lang.org/nightly/std/fs/struct.File.html#method.open" title="associated function std::fs::File::open"><code>fs::File::open</code></a> or
<a href="https://doc.rust-lang.org/nightly/std/fs/struct.OpenOptions.html#method.open" title="method std::fs::OpenOptions::open"><code>fs::OpenOptions::open</code></a> for more information.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_dir" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.5.0">1.5.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#2978">source</a></span><h4 class="code-header">pub fn <a href="#method.is_dir" class="fn">is_dir</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the path exists on disk and is pointing at a directory.</p>
<p>This function will traverse symbolic links to query information about the
destination file.</p>
<p>If you cannot access the metadata of the file, e.g. because of a
permission error or broken symbolic links, this will return <code>false</code>.</p>
<h5 id="examples-30"><a class="doc-anchor" href="#examples-30">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"./is_a_directory/"</span>).is_dir(), <span class="bool-val">true</span>);
<span class="macro">assert_eq!</span>(Path::new(<span class="string">"a_file.txt"</span>).is_dir(), <span class="bool-val">false</span>);</code></pre></div>
<h5 id="see-also-4"><a class="doc-anchor" href="#see-also-4">§</a>See Also</h5>
<p>This is a convenience function that coerces errors to false. If you want to
check errors, call <a href="https://doc.rust-lang.org/nightly/std/fs/fn.metadata.html" title="fn std::fs::metadata"><code>fs::metadata</code></a> and handle its <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a>. Then call
<a href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html#method.is_dir" title="method std::fs::Metadata::is_dir"><code>fs::Metadata::is_dir</code></a> if it was <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.is_symlink" class="method"><span class="rightside"><span class="since" title="Stable since Rust version 1.58.0">1.58.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/std/path.rs.html#3010">source</a></span><h4 class="code-header">pub fn <a href="#method.is_symlink" class="fn">is_symlink</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class="docblock"><p>Returns <code>true</code> if the path exists on disk and is pointing at a symbolic link.</p>
<p>This function will not traverse symbolic links.
In case of a broken symbolic link this will also return true.</p>
<p>If you cannot access the directory containing the file, e.g., because of a
permission error, this will return false.</p>
<h5 id="examples-31"><a class="doc-anchor" href="#examples-31">§</a>Examples</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::path::Path;
<span class="kw">use </span>std::os::unix::fs::symlink;
<span class="kw">let </span>link_path = Path::new(<span class="string">"link"</span>);
symlink(<span class="string">"/origin_does_not_exist/"</span>, link_path).unwrap();
<span class="macro">assert_eq!</span>(link_path.is_symlink(), <span class="bool-val">true</span>);
<span class="macro">assert_eq!</span>(link_path.exists(), <span class="bool-val">false</span>);</code></pre></div>
<h5 id="see-also-5"><a class="doc-anchor" href="#see-also-5">§</a>See Also</h5>
<p>This is a convenience function that coerces errors to false. If you want to
check errors, call <a href="https://doc.rust-lang.org/nightly/std/fs/fn.symlink_metadata.html" title="fn std::fs::symlink_metadata"><code>fs::symlink_metadata</code></a> and handle its <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result"><code>Result</code></a>. Then call
<a href="https://doc.rust-lang.org/nightly/std/fs/struct.Metadata.html#method.is_symlink" title="method std::fs::Metadata::is_symlink"><code>fs::Metadata::is_symlink</code></a> if it was <a href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html#variant.Ok" title="variant core::result::Result::Ok"><code>Ok</code></a>.</p>
</div></details></div><h2 id="trait-implementations" class="section-header">Trait Implementations<a href="#trait-implementations" class="anchor">§</a></h2><div id="trait-implementations-list"><details class="toggle implementors-toggle" open><summary><section id="impl-AsRef%3COsStr%3E-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#618-622">source</a><a href="#impl-AsRef%3COsStr%3E-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a>> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_ref" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#619-621">source</a><a href="#method.as_ref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fn">as_ref</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/ffi/os_str/struct.OsStr.html" title="struct std::ffi::os_str::OsStr">OsStr</a></h4></section></summary><div class='docblock'>Converts this type into a shared reference of the (usually inferred) input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-AsRef%3CPath%3E-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#612-616">source</a><a href="#impl-AsRef%3CPath%3E-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html" title="trait core::convert::AsRef">AsRef</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a>> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.as_ref-1" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#613-615">source</a><a href="#method.as_ref-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.AsRef.html#tymethod.as_ref" class="fn">as_ref</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></h4></section></summary><div class='docblock'>Converts this type into a shared reference of the (usually inferred) input type.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Clone-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#impl-Clone-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&self) -> <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h4></section></summary><div class='docblock'>Returns a copy of the value. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#tymethod.clone">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_from" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#172">source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&mut self, source: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&Self</a>)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html#method.clone_from">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Debug-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#598-602">source</a><a href="#impl-Debug-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.fmt" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#599-601">source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&self, f: &mut <a class="struct" href="https://doc.rust-lang.org/nightly/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a><'_>) -> <a class="type" href="https://doc.rust-lang.org/nightly/core/fmt/type.Result.html" title="type core::fmt::Result">Result</a></h4></section></summary><div class='docblock'>Formats the value using the given formatter. <a href="https://doc.rust-lang.org/nightly/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Deref-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#604-610">source</a><a href="#impl-Deref-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Target" class="associatedtype trait-impl"><a href="#associatedtype.Target" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#associatedtype.Target" class="associatedtype">Target</a> = <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></h4></section></summary><div class='docblock'>The resulting type after dereferencing.</div></details><details class="toggle method-toggle" open><summary><section id="method.deref" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#607-609">source</a><a href="#method.deref" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/ops/deref/trait.Deref.html#tymethod.deref" class="fn">deref</a>(&self) -> &<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.Path.html" title="struct std::path::Path">Path</a></h4></section></summary><div class='docblock'>Dereferences the value.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CCanonicalPath%3E-for-PathBuf" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#630-634">source</a><a href="#impl-PartialEq%3CCanonicalPath%3E-for-PathBuf" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>> for <a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq-2" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#631-633">source</a><a href="#method.eq-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne-2" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#262">source</a></span><a href="#method.ne-2" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq%3CPathBuf%3E-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#624-628">source</a><a href="#impl-PartialEq%3CPathBuf%3E-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a><<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq-1" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#625-627">source</a><a href="#method.eq-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="https://doc.rust-lang.org/nightly/std/path/struct.PathBuf.html" title="struct std::path::PathBuf">PathBuf</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne-1" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#262">source</a></span><a href="#method.ne-1" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-PartialEq-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#impl-PartialEq-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html" title="trait core::cmp::PartialEq">PartialEq</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.eq" class="method trait-impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#method.eq" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#tymethod.eq" class="fn">eq</a>(&self, other: &<a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>self</code> and <code>other</code> values to be equal, and is used
by <code>==</code>.</div></details><details class="toggle method-toggle" open><summary><section id="method.ne" class="method trait-impl"><span class="rightside"><span class="since" title="Stable since Rust version 1.0.0">1.0.0</span> · <a class="src" href="https://doc.rust-lang.org/nightly/src/core/cmp.rs.html#262">source</a></span><a href="#method.ne" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/cmp/trait.PartialEq.html#method.ne" class="fn">ne</a>(&self, other: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&Rhs</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a></h4></section></summary><div class='docblock'>This method tests for <code>!=</code>. The default implementation is almost always
sufficient, and should not be overridden without very good reason.</div></details></div></details><section id="impl-Eq-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#impl-Eq-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/cmp/trait.Eq.html" title="trait core::cmp::Eq">Eq</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-StructuralPartialEq-for-CanonicalPath" class="impl"><a class="src rightside" href="../src/which/lib.rs.html#517">source</a><a href="#impl-StructuralPartialEq-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.StructuralPartialEq.html" title="trait core::marker::StructuralPartialEq">StructuralPartialEq</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></div><h2 id="synthetic-implementations" class="section-header">Auto Trait Implementations<a href="#synthetic-implementations" class="anchor">§</a></h2><div id="synthetic-implementations-list"><section id="impl-Freeze-for-CanonicalPath" class="impl"><a href="#impl-Freeze-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-RefUnwindSafe-for-CanonicalPath" class="impl"><a href="#impl-RefUnwindSafe-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-Send-for-CanonicalPath" class="impl"><a href="#impl-Send-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-Sync-for-CanonicalPath" class="impl"><a href="#impl-Sync-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-Unpin-for-CanonicalPath" class="impl"><a href="#impl-Unpin-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section><section id="impl-UnwindSafe-for-CanonicalPath" class="impl"><a href="#impl-UnwindSafe-for-CanonicalPath" class="anchor">§</a><h3 class="code-header">impl <a class="trait" href="https://doc.rust-lang.org/nightly/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.CanonicalPath.html" title="struct which::CanonicalPath">CanonicalPath</a></h3></section></div><h2 id="blanket-implementations" class="section-header">Blanket Implementations<a href="#blanket-implementations" class="anchor">§</a></h2><div id="blanket-implementations-list"><details class="toggle implementors-toggle"><summary><section id="impl-Any-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#140">source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html" title="trait core::any::Any">Any</a> for T<div class="where">where
T: 'static + ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.type_id" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/any.rs.html#141">source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&self) -> <a class="struct" href="https://doc.rust-lang.org/nightly/core/any/struct.TypeId.html" title="struct core::any::TypeId">TypeId</a></h4></section></summary><div class='docblock'>Gets the <code>TypeId</code> of <code>self</code>. <a href="https://doc.rust-lang.org/nightly/core/any/trait.Any.html#tymethod.type_id">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Borrow%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#208">source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#210">source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.Borrow.html#tymethod.borrow">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-BorrowMut%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#216">source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a><T> for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/nightly/core/marker/trait.Sized.html" title="trait core::marker::Sized">Sized</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.borrow_mut" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/borrow.rs.html#217">source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&mut self) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/nightly/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-CloneToUninit-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#271">source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.CloneToUninit.html" title="trait core::clone::CloneToUninit">CloneToUninit</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.clone_to_uninit" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/clone.rs.html#272">source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">default unsafe fn <a href="https://doc.rust-lang.org/nightly/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&self, dst: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.pointer.html">*mut T</a>)</h4></section></summary><span class="item-info"><div class="stab unstable"><span class="emoji">🔬</span><span>This is a nightly-only experimental API. (<code>clone_to_uninit</code>)</span></div></span><div class='docblock'>Performs copy-assignment from <code>self</code> to <code>dst</code>. <a href="https://doc.rust-lang.org/nightly/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-From%3CT%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#765">source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#768">source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -> T</h4></section></summary><div class="docblock"><p>Returns the argument unchanged.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-Into%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#748-750">source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#758">source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -> U</h4></section></summary><div class="docblock"><p>Calls <code>U::from(self)</code>.</p>
<p>That is, this conversion is whatever the implementation of
<code><a href="https://doc.rust-lang.org/nightly/core/convert/trait.From.html" title="trait core::convert::From">From</a><T> for U</code> chooses to do.</p>
</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-IntoEither-for-T" class="impl"><a class="src rightside" href="../src/either/into_either.rs.html#64">source</a><a href="#impl-IntoEither-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="../either/into_either/trait.IntoEither.html" title="trait either::into_either::IntoEither">IntoEither</a> for T</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.into_either" class="method trait-impl"><a class="src rightside" href="../src/either/into_either.rs.html#29">source</a><a href="#method.into_either" class="anchor">§</a><h4 class="code-header">fn <a href="../either/into_either/trait.IntoEither.html#method.into_either" class="fn">into_either</a>(self, into_left: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>) -> <a class="enum" href="../either/enum.Either.html" title="enum either::Either">Either</a><Self, Self></h4></section></summary><div class='docblock'>Converts <code>self</code> into a <a href="../either/enum.Either.html#variant.Left" title="variant either::Either::Left"><code>Left</code></a> variant of <a href="../either/enum.Either.html" title="enum either::Either"><code>Either<Self, Self></code></a>
if <code>into_left</code> is <code>true</code>.
Converts <code>self</code> into a <a href="../either/enum.Either.html#variant.Right" title="variant either::Either::Right"><code>Right</code></a> variant of <a href="../either/enum.Either.html" title="enum either::Either"><code>Either<Self, Self></code></a>
otherwise. <a href="../either/into_either/trait.IntoEither.html#method.into_either">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.into_either_with" class="method trait-impl"><a class="src rightside" href="../src/either/into_either.rs.html#55-57">source</a><a href="#method.into_either_with" class="anchor">§</a><h4 class="code-header">fn <a href="../either/into_either/trait.IntoEither.html#method.into_either_with" class="fn">into_either_with</a><F>(self, into_left: F) -> <a class="enum" href="../either/enum.Either.html" title="enum either::Either">Either</a><Self, Self><div class="where">where
F: <a class="trait" href="https://doc.rust-lang.org/nightly/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(<a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&Self</a>) -> <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.bool.html">bool</a>,</div></h4></section></summary><div class='docblock'>Converts <code>self</code> into a <a href="../either/enum.Either.html#variant.Left" title="variant either::Either::Left"><code>Left</code></a> variant of <a href="../either/enum.Either.html" title="enum either::Either"><code>Either<Self, Self></code></a>
if <code>into_left(&self)</code> returns <code>true</code>.
Converts <code>self</code> into a <a href="../either/enum.Either.html#variant.Right" title="variant either::Either::Right"><code>Right</code></a> variant of <a href="../either/enum.Either.html" title="enum either::Either"><code>Either<Self, Self></code></a>
otherwise. <a href="../either/into_either/trait.IntoEither.html#method.into_either_with">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-ToOwned-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#83-85">source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl<T> <a class="trait" href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html" title="trait alloc::borrow::ToOwned">ToOwned</a> for T<div class="where">where
T: <a class="trait" href="https://doc.rust-lang.org/nightly/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Owned" class="associatedtype trait-impl"><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#associatedtype.Owned" class="associatedtype">Owned</a> = T</h4></section></summary><div class='docblock'>The resulting type after obtaining ownership.</div></details><details class="toggle method-toggle" open><summary><section id="method.to_owned" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#88">source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&self) -> T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#tymethod.to_owned">Read more</a></div></details><details class="toggle method-toggle" open><summary><section id="method.clone_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/alloc/borrow.rs.html#92">source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&self, target: <a class="primitive" href="https://doc.rust-lang.org/nightly/std/primitive.reference.html">&mut T</a>)</h4></section></summary><div class='docblock'>Uses borrowed data to replace owned data, usually by cloning. <a href="https://doc.rust-lang.org/nightly/alloc/borrow/trait.ToOwned.html#method.clone_into">Read more</a></div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryFrom%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#805-807">source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/nightly/core/convert/enum.Infallible.html" title="enum core::convert::Infallible">Infallible</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_from" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#812">source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><T, <T as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><U>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details><details class="toggle implementors-toggle"><summary><section id="impl-TryInto%3CU%3E-for-T" class="impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#790-792">source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl<T, U> <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a><U> for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a></h4></section></summary><div class='docblock'>The type returned in the event of a conversion error.</div></details><details class="toggle method-toggle" open><summary><section id="method.try_into" class="method trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/nightly/src/core/convert/mod.rs.html#797">source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/nightly/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -> <a class="enum" href="https://doc.rust-lang.org/nightly/core/result/enum.Result.html" title="enum core::result::Result">Result</a><U, <U as <a class="trait" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a><T>>::<a class="associatedtype" href="https://doc.rust-lang.org/nightly/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>></h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>