<!DOCTYPE html><htmllang="en"><head><metacharset="utf-8"><metaname="viewport"content="width=device-width, initial-scale=1.0"><metaname="generator"content="rustdoc"><metaname="description"content="Provides methods for converting a type `Self` into either a `Left` or `Right` variant of `Either<Self, Self>`."><title>IntoEither in either - 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><linkrel="stylesheet"href="../static.files/normalize-76eba96aa4d2e634.css"><linkrel="stylesheet"href="../static.files/rustdoc-dd39b87e5fcfba68.css"><metaname="rustdoc-vars"data-root-path="../"data-static-root-path="../static.files/"data-current-crate="either"data-themes=""data-resource-suffix=""data-rustdoc-version="1.80.0 (051478957 2024-07-21)"data-channel="1.80.0"data-search-js="search-d52510db62a78183.js"data-settings-js="settings-4313503d2e1961c2.js"><scriptsrc="../static.files/storage-118b08c4c78b968e.js"></script><scriptdefersrc="sidebar-items.js"></script><scriptdefersrc="../static.files/main-20a3ad099b048cf2.js"></script><noscript><linkrel="stylesheet"href="../static.files/noscript-df360f571f6edeae.css"></noscript><linkrel="alternate icon"type="image/png"href="../static.files/favicon-32x32-422f7d1d52889060.png"><linkrel="icon"type="image/svg+xml"href="../static.files/favicon-2c020d218678b618.svg"></head><bodyclass="rustdoc trait"><!--[if lte IE 11]><div class="warning">This old browser is unsupported and will most likely display funky things.</div><![endif]--><navclass="mobile-topbar"><buttonclass="sidebar-menu-toggle"title="show sidebar"></button></nav><navclass="sidebar"><divclass="sidebar-crate"><h2><ahref="../either/index.html">either</a><spanclass="version">1.13.0</span></h2></div><h2class="location"><ahref="#">IntoEither</a></h2><divclass="sidebar-elems"><section><h3><ahref="#provided-methods">Provided Methods</a></h3><ulclass="block"><li><ahref="#method.into_either">into_either</a></li><li><ahref="#method.into_either_with">into_either_with</a></li></ul><h3><ahref="#object-safety">Object Safety</a></h3><h3><ahref="#implementors">Implementors</a></h3></section><h2><ahref="index.html">In crate either</a></h2></div></nav><divclass="sidebar-resizer"></div><main><divclass="width-limiter"><rustdoc-search></rustdoc-search><sectionid="main-content"class="content"><divclass="main-heading"><h1>Trait <ahref="index.html">either</a>::<wbr><aclass="trait"href="#">IntoEither</a><buttonid="copy-path"title="Copy item path to clipboard">Copy item path</button></h1><spanclass="out-of-band"><aclass="src"href="../src/either/into_either.rs.html#14-62">source</a> · <buttonid="toggle-all-docs"title="collapse all docs">[<span>−</span>]</button></span></div><preclass="rust item-decl"><code>pub trait IntoEither: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/marker/trait.Sized.html"title="trait core::marker::Sized">Sized</a> {
}</code></pre><detailsclass="toggle top-doc"open><summaryclass="hideme"><span>Expand description</span></summary><divclass="docblock"><p>Provides methods for converting a type <code>Self</code> into either a <ahref="enum.Either.html#variant.Left"title="variant either::Either::Left"><code>Left</code></a> or <ahref="enum.Either.html#variant.Right"title="variant either::Either::Right"><code>Right</code></a>
variant of <ahref="enum.Either.html"title="enum either::Either"><code>Either<Self, Self></code></a>.</p>
<p>The <ahref="trait.IntoEither.html#method.into_either"title="method either::IntoEither::into_either"><code>into_either</code></a> method takes a <ahref="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html"title="primitive bool"><code>bool</code></a> to determine
whether to convert to <ahref="enum.Either.html#variant.Left"title="variant either::Either::Left"><code>Left</code></a> or <ahref="enum.Either.html#variant.Right"title="variant either::Either::Right"><code>Right</code></a>.</p>
<p>The <ahref="trait.IntoEither.html#method.into_either_with"title="method either::IntoEither::into_either_with"><code>into_either_with</code></a> method takes a
<ahref="https://doc.rust-lang.org/1.80.0/core/ops/function/trait.FnOnce.html"title="trait core::ops::function::FnOnce">predicate function</a> to determine whether to convert to <ahref="enum.Either.html#variant.Left"title="variant either::Either::Left"><code>Left</code></a> or <ahref="enum.Either.html#variant.Right"title="variant either::Either::Right"><code>Right</code></a>.</p>
</div></details><h2id="provided-methods"class="section-header">Provided Methods<ahref="#provided-methods"class="anchor">§</a></h2><divclass="methods"><detailsclass="toggle method-toggle"open><summary><sectionid="method.into_either"class="method"><aclass="src rightside"href="../src/either/into_either.rs.html#29-35">source</a><h4class="code-header">fn <ahref="#method.into_either"class="fn">into_either</a>(self, into_left: <aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>) -><aclass="enum"href="enum.Either.html"title="enum either::Either">Either</a><Self, Self><ahref="#"class="tooltip"data-notable-ty="Either<Self, Self>">ⓘ</a></h4></section></summary><divclass="docblock"><p>Converts <code>self</code> into a <ahref="enum.Either.html#variant.Left"title="variant either::Either::Left"><code>Left</code></a> variant of <ahref="enum.Either.html"title="enum either::Either"><code>Either<Self, Self></code></a>
Converts <code>self</code> into a <ahref="enum.Either.html#variant.Right"title="variant either::Either::Right"><code>Right</code></a> variant of <ahref="enum.Either.html"title="enum either::Either"><code>Either<Self, Self></code></a>
F: <aclass="trait"href="https://doc.rust-lang.org/1.80.0/core/ops/function/trait.FnOnce.html"title="trait core::ops::function::FnOnce">FnOnce</a>(<aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.reference.html">&Self</a>) -><aclass="primitive"href="https://doc.rust-lang.org/1.80.0/std/primitive.bool.html">bool</a>,</div></h4></section></summary><divclass="docblock"><p>Converts <code>self</code> into a <ahref="enum.Either.html#variant.Left"title="variant either::Either::Left"><code>Left</code></a> variant of <ahref="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 <ahref="enum.Either.html#variant.Right"title="variant either::Either::Right"><code>Right</code></a> variant of <ahref="enum.Either.html"title="enum either::Either"><code>Either<Self, Self></code></a>
</div></details></div><h2id="object-safety"class="section-header">Object Safety<ahref="#object-safety"class="anchor">§</a></h2><divclass="object-safety-info">This trait is <b>not</b><ahref="https://doc.rust-lang.org/1.80.0/reference/items/traits.html#object-safety">object safe</a>.</div><h2id="implementors"class="section-header">Implementors<ahref="#implementors"class="anchor">§</a></h2><divid="implementors-list"><sectionid="impl-IntoEither-for-T"class="impl"><aclass="src rightside"href="../src/either/into_either.rs.html#64">source</a><ahref="#impl-IntoEither-for-T"class="anchor">§</a><h3class="code-header">impl<T><aclass="trait"href="trait.IntoEither.html"title="trait either::IntoEither">IntoEither</a> for T</h3></section></div><scriptsrc="../trait.impl/either/into_either/trait.IntoEither.js"async></script><scripttype="text/json"id="notable-traits-data">{"Either<Self,Self>":"<h3>Notabletraitsfor<code><aclass=\"enum\"href=\"enum.Either.html\"title=\"enumeither::Either\">Either</a><L,R></code></h3><pre><code><divclass=\"where\">impl<L,R><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html\"title=\"traitcore::future::future::Future\">Future</a>for<aclass=\"enum\"href=\"enum.Either.html\"title=\"enumeither::Either\">Either</a><L,R><divclass=\"where\">where\nL:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html\"title=\"traitcore::future::future::Future\">Future</a>,\nR:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html\"title=\"traitcore::future::future::Future\">Future</a><Output=L::<aclass=\"associatedtype\"href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html#associatedtype.Output\"title=\"typecore::future::future::Future::Output\">Output</a>>,</div></div><divclass=\"where\">type<ahref=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html#associatedtype.Output\"class=\"associatedtype\">Output</a>=L::<aclass=\"associatedtype\"href=\"https://doc.rust-lang.org/1.80.0/core/future/future/trait.Future.html#associatedtype.Output\"title=\"typecore::future::future::Future::Output\">Output</a>;</div><divclass=\"where\">impl<L,R><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Write.html\"title=\"traitstd::io::Write\">Write</a>for<aclass=\"enum\"href=\"enum.Either.html\"title=\"enumeither::Either\">Either</a><L,R><divclass=\"where\">where\nL:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Write.html\"title=\"traitstd::io::Write\">Write</a>,\nR:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Write.html\"title=\"traitstd::io::Write\">Write</a>,</div></div><divclass=\"where\">impl<L,R><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Read.html\"title=\"traitstd::io::Read\">Read</a>for<aclass=\"enum\"href=\"enum.Either.html\"title=\"enumeither::Either\">Either</a><L,R><divclass=\"where\">where\nL:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Read.html\"title=\"traitstd::io::Read\">Read</a>,\nR:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/std/io/trait.Read.html\"title=\"traitstd::io::Read\">Read</a>,</div></div><divclass=\"where\">impl<L,R><aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>for<aclass=\"enum\"href=\"enum.Either.html\"title=\"enumeither::Either\">Either</a><L,R><divclass=\"where\">where\nL:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/iter/traits/iterator/trait.Iterator.html\"title=\"traitcore::iter::traits::iterator::Iterator\">Iterator</a>,\nR:<aclass=\"trait\"href=\"https://doc.rust-lang.org/1.80.0/core/iter/traits/iterator/trait.Iterator.html\"title=\