Files
GopherGate/target/doc/yoke/struct.Yoke.html
2026-02-26 12:00:21 -05:00

549 lines
118 KiB
HTML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<!DOCTYPE html><html lang="en"><head><meta charset="utf-8"><meta name="viewport" content="width=device-width, initial-scale=1.0"><meta name="generator" content="rustdoc"><meta name="description" content="A Cow-like borrowed object “yoked” to its backing data."><title>Yoke in yoke - Rust</title><script>if(window.location.protocol!=="file:")document.head.insertAdjacentHTML("beforeend","SourceSerif4-Regular-6b053e98.ttf.woff2,FiraSans-Italic-81dc35de.woff2,FiraSans-Regular-0fe48ade.woff2,FiraSans-MediumItalic-ccf7e434.woff2,FiraSans-Medium-e1aa3f0a.woff2,SourceCodePro-Regular-8badfe75.ttf.woff2,SourceCodePro-Semibold-aa29a496.ttf.woff2".split(",").map(f=>`<link rel="preload" as="font" type="font/woff2"href="../static.files/${f}">`).join(""))</script><link rel="stylesheet" href="../static.files/normalize-9960930a.css"><link rel="stylesheet" href="../static.files/rustdoc-ca0dd0c4.css"><meta name="rustdoc-vars" data-root-path="../" data-static-root-path="../static.files/" data-current-crate="yoke" data-themes="" data-resource-suffix="" data-rustdoc-version="1.93.1 (01f6ddf75 2026-02-11) (Arch Linux rust 1:1.93.1-1)" data-channel="1.93.1" data-search-js="search-9e2438ea.js" data-stringdex-js="stringdex-a3946164.js" data-settings-js="settings-c38705f0.js" ><script src="../static.files/storage-e2aeef58.js"></script><script defer src="sidebar-items.js"></script><script defer src="../static.files/main-a410ff4d.js"></script><noscript><link rel="stylesheet" href="../static.files/noscript-263c88ec.css"></noscript><link rel="alternate icon" type="image/png" href="../static.files/favicon-32x32-eab170b8.png"><link rel="icon" type="image/svg+xml" href="../static.files/favicon-044be391.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]--><rustdoc-topbar><h2><a href="#">Yoke</a></h2></rustdoc-topbar><nav class="sidebar"><div class="sidebar-crate"><h2><a href="../yoke/index.html">yoke</a><span class="version">0.8.1</span></h2></div><div class="sidebar-elems"><section id="rustdoc-toc"><h2 class="location"><a href="#">Yoke</a></h2><h3><a href="#">Sections</a></h3><ul class="block top-toc"><li><a href="#example" title="Example">Example</a></li></ul><h3><a href="#implementations">Methods</a></h3><ul class="block method"><li><a href="#method.attach_to_cart" title="attach_to_cart">attach_to_cart</a></li><li><a href="#method.attach_to_cart_badly" title="attach_to_cart_badly">attach_to_cart_badly</a></li><li><a href="#method.attach_to_zero_copy_cart" title="attach_to_zero_copy_cart">attach_to_zero_copy_cart</a></li><li><a href="#method.backing_cart" title="backing_cart">backing_cart</a></li><li><a href="#method.convert_cart_into_option_pointer" title="convert_cart_into_option_pointer">convert_cart_into_option_pointer</a></li><li><a href="#method.get" title="get">get</a></li><li><a href="#method.into_backing_cart" title="into_backing_cart">into_backing_cart</a></li><li><a href="#method.into_yokeable" title="into_yokeable">into_yokeable</a></li><li><a href="#method.map_project" title="map_project">map_project</a></li><li><a href="#method.map_project_cloned" title="map_project_cloned">map_project_cloned</a></li><li><a href="#method.map_project_cloned_with_explicit_capture" title="map_project_cloned_with_explicit_capture">map_project_cloned_with_explicit_capture</a></li><li><a href="#method.map_project_with_explicit_capture" title="map_project_with_explicit_capture">map_project_with_explicit_capture</a></li><li><a href="#method.map_with_cart" title="map_with_cart">map_with_cart</a></li><li><a href="#method.map_with_cart_cloned" title="map_with_cart_cloned">map_with_cart_cloned</a></li><li><a href="#method.new_always_owned" title="new_always_owned">new_always_owned</a></li><li><a href="#method.new_owned" title="new_owned">new_owned</a></li><li><a href="#method.replace_cart" title="replace_cart">replace_cart</a></li><li><a href="#method.try_attach_to_cart" title="try_attach_to_cart">try_attach_to_cart</a></li><li><a href="#method.try_attach_to_cart_badly" title="try_attach_to_cart_badly">try_attach_to_cart_badly</a></li><li><a href="#method.try_into_yokeable" title="try_into_yokeable">try_into_yokeable</a></li><li><a href="#method.try_into_yokeable-1" title="try_into_yokeable">try_into_yokeable</a></li><li><a href="#method.try_map_project" title="try_map_project">try_map_project</a></li><li><a href="#method.try_map_project_cloned" title="try_map_project_cloned">try_map_project_cloned</a></li><li><a href="#method.try_map_project_cloned_with_explicit_capture" title="try_map_project_cloned_with_explicit_capture">try_map_project_cloned_with_explicit_capture</a></li><li><a href="#method.try_map_project_with_explicit_capture" title="try_map_project_with_explicit_capture">try_map_project_with_explicit_capture</a></li><li><a href="#method.try_map_with_cart" title="try_map_with_cart">try_map_with_cart</a></li><li><a href="#method.try_map_with_cart_cloned" title="try_map_with_cart_cloned">try_map_with_cart_cloned</a></li><li><a href="#method.with_mut" title="with_mut">with_mut</a></li><li><a href="#method.with_mut_return" title="with_mut_return">with_mut_return</a></li><li><a href="#method.wrap_cart_in_either_a" title="wrap_cart_in_either_a">wrap_cart_in_either_a</a></li><li><a href="#method.wrap_cart_in_either_b" title="wrap_cart_in_either_b">wrap_cart_in_either_b</a></li><li><a href="#method.wrap_cart_in_option" title="wrap_cart_in_option">wrap_cart_in_option</a></li></ul><h3><a href="#trait-implementations">Trait Implementations</a></h3><ul class="block trait-implementation"><li><a href="#impl-Clone-for-Yoke%3CY,+C%3E" title="Clone">Clone</a></li><li><a href="#impl-Debug-for-Yoke%3CY,+C%3E" title="Debug">Debug</a></li></ul><h3><a href="#synthetic-implementations">Auto Trait Implementations</a></h3><ul class="block synthetic-implementation"><li><a href="#impl-Freeze-for-Yoke%3CY,+C%3E" title="Freeze">Freeze</a></li><li><a href="#impl-RefUnwindSafe-for-Yoke%3CY,+C%3E" title="RefUnwindSafe">RefUnwindSafe</a></li><li><a href="#impl-Send-for-Yoke%3CY,+C%3E" title="Send">Send</a></li><li><a href="#impl-Sync-for-Yoke%3CY,+C%3E" title="Sync">Sync</a></li><li><a href="#impl-Unpin-for-Yoke%3CY,+C%3E" title="Unpin">Unpin</a></li><li><a href="#impl-UnwindSafe-for-Yoke%3CY,+C%3E" title="UnwindSafe">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" title="Any">Any</a></li><li><a href="#impl-Borrow%3CT%3E-for-T" title="Borrow&#60;T&#62;">Borrow&#60;T&#62;</a></li><li><a href="#impl-BorrowMut%3CT%3E-for-T" title="BorrowMut&#60;T&#62;">BorrowMut&#60;T&#62;</a></li><li><a href="#impl-CloneToUninit-for-T" title="CloneToUninit">CloneToUninit</a></li><li><a href="#impl-From%3CT%3E-for-T" title="From&#60;T&#62;">From&#60;T&#62;</a></li><li><a href="#impl-Into%3CU%3E-for-T" title="Into&#60;U&#62;">Into&#60;U&#62;</a></li><li><a href="#impl-ToOwned-for-T" title="ToOwned">ToOwned</a></li><li><a href="#impl-TryFrom%3CU%3E-for-T" title="TryFrom&#60;U&#62;">TryFrom&#60;U&#62;</a></li><li><a href="#impl-TryInto%3CU%3E-for-T" title="TryInto&#60;U&#62;">TryInto&#60;U&#62;</a></li></ul></section><div id="rustdoc-modnav"><h2 class="in-crate"><a href="index.html">In crate yoke</a></h2></div></div></nav><div class="sidebar-resizer" title="Drag to resize sidebar"></div><main><div class="width-limiter"><section id="main-content" class="content"><div class="main-heading"><div class="rustdoc-breadcrumbs"><a href="index.html">yoke</a></div><h1>Struct <span class="struct">Yoke</span>&nbsp;<button id="copy-path" title="Copy item path to clipboard">Copy item path</button></h1><rustdoc-toolbar></rustdoc-toolbar><span class="sub-heading"><a class="src" href="../src/yoke/yoke.rs.html#79-93">Source</a> </span></div><pre class="rust item-decl"><code>pub struct Yoke&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C&gt; { <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>A Cow-like borrowed object “yoked” to its backing data.</p>
<p>This allows things like zero copy deserialized data to carry around
shared references to their backing buffer, by “erasing” their static lifetime
and turning it into a dynamically managed one.</p>
<p><code>Y</code> (the <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a>) is the object containing the references,
and will typically be of the form <code>Foo&lt;'static&gt;</code>. The <code>'static</code> is
not the actual lifetime of the data, rather it is a convenient way to mark the
erased lifetime and make it dynamic.</p>
<p><code>C</code> is the “cart”, which <code>Y</code> may contain references to. After the yoke is constructed,
the cart serves little purpose except to guarantee that <code>Y</code>s references remain valid
for as long as the yoke remains in memory (by calling the destructor at the appropriate moment).</p>
<p>The primary constructor for <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> is <a href="struct.Yoke.html#method.attach_to_cart" title="associated function yoke::Yoke::attach_to_cart"><code>Yoke::attach_to_cart()</code></a>. Several variants of that
constructor are provided to serve numerous types of call sites and <code>Yoke</code> signatures.</p>
<p>The key behind this type is <a href="struct.Yoke.html#method.get" title="method yoke::Yoke::get"><code>Yoke::get()</code></a>, where calling <a href="struct.Yoke.html#method.get" title="method yoke::Yoke::get"><code>.get()</code></a> on a type like
<code>Yoke&lt;Cow&lt;'static, str&gt;, _&gt;</code> will get you a short-lived <code>&amp;'a Cow&lt;'a, str&gt;</code>, restricted to the
lifetime of the borrow used during <code>.get()</code>. This is entirely safe since the <code>Cow</code> borrows from
the cart type <code>C</code>, which cannot be interfered with as long as the <code>Yoke</code> is borrowed by <code>.get ()</code>. <code>.get()</code> protects access by essentially reifying the erased lifetime to a safe local one
when necessary.</p>
<p>Furthermore, there are various <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>.map_project()</code></a> methods that allow turning a <code>Yoke</code>
into another <code>Yoke</code> containing a different type that may contain elements of the original yoked
value. See the <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project()</code></a> docs for more details.</p>
<p>In general, <code>C</code> is a concrete type, but it is also possible for it to be a trait object.</p>
<h2 id="example"><a class="doc-anchor" href="#example">§</a>Example</h2>
<p>For example, we can use this to store zero-copy deserialized data in a cache:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">fn </span>load_object(filename: <span class="kw-2">&amp;</span>str) -&gt; Yoke&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt; {
<span class="kw">let </span>rc: Rc&lt;[u8]&gt; = load_from_cache(filename);
Yoke::&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt;::attach_to_cart(rc, |data: <span class="kw-2">&amp;</span>[u8]| {
<span class="comment">// essentially forcing a #[serde(borrow)]
</span>Cow::Borrowed(bincode::deserialize(data).unwrap())
})
}
<span class="kw">let </span>yoke = load_object(<span class="string">"filename.bincode"</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;**</span>yoke.get(), <span class="string">"hello"</span>);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(yoke.get(), <span class="kw-2">&amp;</span>Cow::Borrowed(<span class="kw">_</span>)));</code></pre></div></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-Yoke%3CY,+C%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#121-259">Source</a><a href="#impl-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="../stable_deref_trait/trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a>&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.attach_to_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#193-214">Source</a><h4 class="code-header">pub fn <a href="#method.attach_to_cart" class="fn">attach_to_cart</a>&lt;F&gt;(cart: C, f: F) -&gt; Self<div class="where">where
F: for&lt;'de&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'de &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'de&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>Construct a <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> by yokeing an object to a cart in a closure.</p>
<p>The closure can read and write data outside of its scope, but data it returns
may borrow only from the argument passed to the closure.</p>
<p>See also <a href="struct.Yoke.html#method.try_attach_to_cart" title="associated function yoke::Yoke::try_attach_to_cart"><code>Yoke::try_attach_to_cart()</code></a> to return a <code>Result</code> from the closure.</p>
<p>Call sites for this function may not compile pre-1.61; if this still happens, use
<a href="struct.Yoke.html#method.attach_to_cart_badly" title="associated function yoke::Yoke::attach_to_cart_badly"><code>Yoke::attach_to_cart_badly()</code></a> and file a bug.</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">fn </span>load_object(filename: <span class="kw-2">&amp;</span>str) -&gt; Yoke&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt; {
<span class="kw">let </span>rc: Rc&lt;[u8]&gt; = load_from_cache(filename);
Yoke::&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt;::attach_to_cart(rc, |data: <span class="kw-2">&amp;</span>[u8]| {
<span class="comment">// essentially forcing a #[serde(borrow)]
</span>Cow::Borrowed(bincode::deserialize(data).unwrap())
})
}
<span class="kw">let </span>yoke: Yoke&lt;Cow&lt;str&gt;, <span class="kw">_</span>&gt; = load_object(<span class="string">"filename.bincode"</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;**</span>yoke.get(), <span class="string">"hello"</span>);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(yoke.get(), <span class="kw-2">&amp;</span>Cow::Borrowed(<span class="kw">_</span>)));</code></pre></div>
<p>Write the number of consumed bytes to a local variable:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">fn </span>load_object(
filename: <span class="kw-2">&amp;</span>str,
) -&gt; (Yoke&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt;, usize) {
<span class="kw">let </span>rc: Rc&lt;[u8]&gt; = load_from_cache(filename);
<span class="kw">let </span><span class="kw-2">mut </span>bytes_remaining = <span class="number">0</span>;
<span class="kw">let </span>bytes_remaining = <span class="kw-2">&amp;mut </span>bytes_remaining;
<span class="kw">let </span>yoke = Yoke::&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Rc&lt;[u8]&gt;&gt;::attach_to_cart(
rc,
|data: <span class="kw-2">&amp;</span>[u8]| {
<span class="kw">let </span><span class="kw-2">mut </span>d = postcard::Deserializer::from_bytes(data);
<span class="kw">let </span>output = serde::Deserialize::deserialize(<span class="kw-2">&amp;mut </span>d);
<span class="kw-2">*</span>bytes_remaining = d.finalize().unwrap().len();
Cow::Borrowed(output.unwrap())
},
);
(yoke, <span class="kw-2">*</span>bytes_remaining)
}
<span class="kw">let </span>(yoke, bytes_remaining) = load_object(<span class="string">"filename.postcard"</span>);
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;**</span>yoke.get(), <span class="string">"hello"</span>);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(yoke.get(), <span class="kw-2">&amp;</span>Cow::Borrowed(<span class="kw">_</span>)));
<span class="macro">assert_eq!</span>(bytes_remaining, <span class="number">3</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.try_attach_to_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#221-236">Source</a><h4 class="code-header">pub fn <a href="#method.try_attach_to_cart" class="fn">try_attach_to_cart</a>&lt;E, F&gt;(cart: C, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, E&gt;<div class="where">where
F: for&lt;'de&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'de &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'de&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>Construct a <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> by yokeing an object to a cart. If an error occurs in the
deserializer function, the error is passed up to the caller.</p>
<p>Call sites for this function may not compile pre-1.61; if this still happens, use
<a href="struct.Yoke.html#method.try_attach_to_cart_badly" title="associated function yoke::Yoke::try_attach_to_cart_badly"><code>Yoke::try_attach_to_cart_badly()</code></a> and file a bug.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.attach_to_cart_badly" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#242-247">Source</a><h4 class="code-header">pub fn <a href="#method.attach_to_cart_badly" class="fn">attach_to_cart_badly</a>(
cart: C,
f: for&lt;'de&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(&amp;'de &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'de&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
) -&gt; Self</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated</span></div></span></summary><div class="docblock"><p>Use <a href="struct.Yoke.html#method.attach_to_cart" title="associated function yoke::Yoke::attach_to_cart"><code>Yoke::attach_to_cart()</code></a>.</p>
<p>This was needed because the pre-1.61 compiler couldnt always handle the FnOnce trait bound.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_attach_to_cart_badly" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#253-258">Source</a><h4 class="code-header">pub fn <a href="#method.try_attach_to_cart_badly" class="fn">try_attach_to_cart_badly</a>&lt;E&gt;(
cart: C,
f: for&lt;'de&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(&amp;'de &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'de&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Self, E&gt;</h4></section><span class="item-info"><div class="stab deprecated"><span class="emoji">👎</span><span>Deprecated</span></div></span></summary><div class="docblock"><p>Use <a href="struct.Yoke.html#method.try_attach_to_cart" title="associated function yoke::Yoke::try_attach_to_cart"><code>Yoke::try_attach_to_cart()</code></a>.</p>
<p>This was needed because the pre-1.61 compiler couldnt always handle the FnOnce trait bound.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+C%3E-1" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#261-486">Source</a><a href="#impl-Yoke%3CY,+C%3E-1" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.get" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#292-294">Source</a><h4 class="code-header">pub fn <a href="#method.get" class="fn">get</a>&lt;'a&gt;(&amp;'a self) -&gt; &amp;'a &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a></h4></section></summary><div class="docblock"><p>Obtain a valid reference to the yokeable data</p>
<p>This essentially transforms the lifetime of the internal yokeable data to
be valid.
For example, if youre working with a <code>Yoke&lt;Cow&lt;'static, T&gt;, C&gt;</code>, this
will return an <code>&amp;'a Cow&lt;'a, T&gt;</code></p>
<h5 id="example-1"><a class="doc-anchor" href="#example-1">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="comment">// load_object() defined in the example at the top of this page
</span><span class="kw">let </span>yoke: Yoke&lt;Cow&lt;str&gt;, <span class="kw">_</span>&gt; = load_object(<span class="string">"filename.bincode"</span>);
<span class="macro">assert_eq!</span>(yoke.get(), <span class="string">"hello"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.backing_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#300-302">Source</a><h4 class="code-header">pub fn <a href="#method.backing_cart" class="fn">backing_cart</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;C</a></h4></section></summary><div class="docblock"><p>Get a reference to the backing cart.</p>
<p>This can be useful when building caches, etc. However, if you plan to store the cart
separately from the yoke, read the note of caution below in <a href="struct.Yoke.html#method.into_backing_cart" title="method yoke::Yoke::into_backing_cart"><code>Yoke::into_backing_cart</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.into_backing_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#353-355">Source</a><h4 class="code-header">pub fn <a href="#method.into_backing_cart" class="fn">into_backing_cart</a>(self) -&gt; C</h4></section></summary><div class="docblock"><p>Get the backing cart by value, dropping the yokeable object.</p>
<p><strong>Caution:</strong> Calling this method could cause information saved in the yokeable object but
not the cart to be lost. Use this method only if the yokeable object cannot contain its
own information.</p>
<h5 id="example-2"><a class="doc-anchor" href="#example-2">§</a>Example</h5>
<p>Good example: the yokeable object is only a reference, so no information can be lost.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>yoke::Yoke;
<span class="kw">let </span>local_data = <span class="string">"foo"</span>.to_owned();
<span class="kw">let </span>yoke = Yoke::&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str, Box&lt;String&gt;&gt;::attach_to_zero_copy_cart(
Box::new(local_data),
);
<span class="macro">assert_eq!</span>(<span class="kw-2">*</span>yoke.get(), <span class="string">"foo"</span>);
<span class="comment">// Get back the cart
</span><span class="kw">let </span>cart = yoke.into_backing_cart();
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>cart, <span class="string">"foo"</span>);</code></pre></div>
<p>Bad example: information specified in <code>.with_mut()</code> is lost.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::borrow::Cow;
<span class="kw">use </span>yoke::Yoke;
<span class="kw">let </span>local_data = <span class="string">"foo"</span>.to_owned();
<span class="kw">let </span><span class="kw-2">mut </span>yoke =
Yoke::&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, Box&lt;String&gt;&gt;::attach_to_zero_copy_cart(
Box::new(local_data),
);
<span class="macro">assert_eq!</span>(yoke.get(), <span class="string">"foo"</span>);
<span class="comment">// Override data in the cart
</span>yoke.with_mut(|cow| {
<span class="kw">let </span>mut_str = cow.to_mut();
mut_str.clear();
mut_str.push_str(<span class="string">"bar"</span>);
});
<span class="macro">assert_eq!</span>(yoke.get(), <span class="string">"bar"</span>);
<span class="comment">// Get back the cart
</span><span class="kw">let </span>cart = yoke.into_backing_cart();
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>cart, <span class="string">"foo"</span>); <span class="comment">// WHOOPS!</span></code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.replace_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#383-391">Source</a><h4 class="code-header">pub unsafe fn <a href="#method.replace_cart" class="fn">replace_cart</a>&lt;C2&gt;(self, f: impl <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(C) -&gt; C2) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C2&gt;</h4></section></summary><div class="docblock"><p>Unsafe function for replacing the cart with another</p>
<p>This can be used for type-erasing the cart, for example.</p>
<h5 id="safety"><a class="doc-anchor" href="#safety">§</a>Safety</h5>
<ul>
<li>
<p><code>f()</code> must not panic</p>
</li>
<li>
<p>References from the yokeable <code>Y</code> should still be valid for the lifetime of the
returned cart type <code>C</code>.</p>
<p>For the purpose of determining this, <code>Yoke</code> guarantees that references from the Yokeable
<code>Y</code> into the cart <code>C</code> will never be references into its stack data, only heap data protected
by <code>StableDeref</code>. This does not necessarily mean that <code>C</code> implements <code>StableDeref</code>, rather that
any data referenced by <code>Y</code> must be accessed through a <code>StableDeref</code> impl on something <code>C</code> owns.</p>
<p>Concretely, this means that if <code>C = Option&lt;Rc&lt;T&gt;&gt;</code>, <code>Y</code> may contain references to the <code>T</code> but not
anything else.</p>
</li>
<li>
<p>Lifetimes inside C must not be lengthened, even if they are themselves contravariant.
I.e., if C contains an <code>fn(&amp;'a u8)</code>, it cannot be replaced with `fn(&amp;static u8),
even though that is typically safe.</p>
</li>
</ul>
<p>Typically, this means implementing <code>f</code> as something which <em>wraps</em> the inner cart type <code>C</code>.
<code>Yoke</code> only really cares about destructors for its carts so its fine to erase other
information about the cart, as long as the backing data will still be destroyed at the
same time.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.with_mut" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#455-460">Source</a><h4 class="code-header">pub fn <a href="#method.with_mut" class="fn">with_mut</a>&lt;'a, F&gt;(&amp;'a mut self, f: F)<div class="where">where
F: 'static + for&lt;'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'b mut &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>),</div></h4></section></summary><div class="docblock"><p>Mutate the stored <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> data.</p>
<p>If the callback needs to return <code>'static</code> data, then <a href="struct.Yoke.html#method.with_mut_return" title="method yoke::Yoke::with_mut_return"><code>Yoke::with_mut_return</code></a> can be
used until the next breaking release of <code>yoke</code>, at which time the callback to this
function will be able to return any <code>'static</code> data.</p>
<p>See <a href="trait.Yokeable.html#tymethod.transform_mut" title="method yoke::Yokeable::transform_mut"><code>Yokeable::transform_mut()</code></a> for why this operation is safe.</p>
<h5 id="example-3"><a class="doc-anchor" href="#example-3">§</a>Example</h5>
<p>This can be used to partially mutate the stored data, provided
no <em>new</em> borrowed data is introduced.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="attr">#[derive(Yokeable)]
</span><span class="kw">struct </span>Bar&lt;<span class="lifetime">'a</span>&gt; {
numbers: Cow&lt;<span class="lifetime">'a</span>, [u8]&gt;,
string: Cow&lt;<span class="lifetime">'a</span>, str&gt;,
owned: Vec&lt;u8&gt;,
}
<span class="comment">// `load_object()` deserializes an object from a file
</span><span class="kw">let </span><span class="kw-2">mut </span>bar: Yoke&lt;Bar, <span class="kw">_</span>&gt; = load_object(<span class="string">"filename.bincode"</span>);
<span class="macro">assert_eq!</span>(bar.get().string, <span class="string">"hello"</span>);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(bar.get().string, Cow::Borrowed(<span class="kw">_</span>)));
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>bar.get().numbers, <span class="kw-2">&amp;</span>[<span class="number">0x68</span>, <span class="number">0x65</span>, <span class="number">0x6c</span>, <span class="number">0x6c</span>, <span class="number">0x6f</span>]);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(bar.get().numbers, Cow::Borrowed(<span class="kw">_</span>)));
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>bar.get().owned, <span class="kw-2">&amp;</span>[]);
bar.with_mut(|bar| {
bar.string.to_mut().push_str(<span class="string">" world"</span>);
bar.owned.extend_from_slice(<span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">4</span>, <span class="number">1</span>, <span class="number">5</span>, <span class="number">9</span>]);
});
<span class="macro">assert_eq!</span>(bar.get().string, <span class="string">"hello world"</span>);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(bar.get().string, Cow::Owned(<span class="kw">_</span>)));
<span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>bar.get().owned, <span class="kw-2">&amp;</span>[<span class="number">1</span>, <span class="number">4</span>, <span class="number">1</span>, <span class="number">5</span>, <span class="number">9</span>]);
<span class="comment">// Unchanged and still Cow::Borrowed
</span><span class="macro">assert_eq!</span>(<span class="kw-2">&amp;*</span>bar.get().numbers, <span class="kw-2">&amp;</span>[<span class="number">0x68</span>, <span class="number">0x65</span>, <span class="number">0x6c</span>, <span class="number">0x6c</span>, <span class="number">0x6f</span>]);
<span class="macro">assert!</span>(<span class="macro">matches!</span>(bar.get().numbers, Cow::Borrowed(<span class="kw">_</span>)));</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.with_mut_return" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#471-477">Source</a><h4 class="code-header">pub fn <a href="#method.with_mut_return" class="fn">with_mut_return</a>&lt;'a, F, R&gt;(&amp;'a mut self, f: F) -&gt; R<div class="where">where
F: 'static + for&lt;'b&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'b mut &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>) -&gt; R,
R: 'static,</div></h4></section></summary><div class="docblock"><p>Mutate the stored <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> data, and return <code>'static</code> data (possibly just <code>()</code>).</p>
<p>See <a href="trait.Yokeable.html#tymethod.transform_mut" title="method yoke::Yokeable::transform_mut"><code>Yokeable::transform_mut()</code></a> for why this operation is safe, noting that no
<code>'static</code>.</p>
<h6 id="will-be-removed"><a class="doc-anchor" href="#will-be-removed">§</a>Will be removed</h6>
<p>This method will be removed on the next breaking release of <code>yoke</code>, when the callback of
<a href="struct.Yoke.html#method.with_mut" title="method yoke::Yoke::with_mut"><code>Yoke::with_mut</code></a> will gain the ability to return any <code>R: 'static</code> and supersede this
method.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.wrap_cart_in_option" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#481-485">Source</a><h4 class="code-header">pub fn <a href="#method.wrap_cart_in_option" class="fn">wrap_cart_in_option</a>(self) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;C&gt;&gt;</h4></section></summary><div class="docblock"><p>Helper function allowing one to wrap the cart type <code>C</code> in an <code>Option&lt;T&gt;</code>.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+()%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#488-529">Source</a><a href="#impl-Yoke%3CY,+()%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new_always_owned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#510-517">Source</a><h4 class="code-header">pub fn <a href="#method.new_always_owned" class="fn">new_always_owned</a>(yokeable: Y) -&gt; Self</h4></section></summary><div class="docblock"><p>Construct a new <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> from static data. There will be no
references to <code>cart</code> here since <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a>s are <code>'static</code>,
this is good for e.g. constructing fully owned
<a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a>s with no internal borrowing.</p>
<p>This is similar to <a href="struct.Yoke.html#method.new_owned" title="associated function yoke::Yoke::new_owned"><code>Yoke::new_owned()</code></a> but it does not allow you to
mix the <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> with borrowed data. This is primarily useful
for using <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> in generic scenarios.</p>
<h5 id="example-4"><a class="doc-anchor" href="#example-4">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>owned: Cow&lt;str&gt; = <span class="string">"hello"</span>.to_owned().into();
<span class="comment">// this yoke can be intermingled with actually-borrowed Yokes
</span><span class="kw">let </span>yoke: Yoke&lt;Cow&lt;str&gt;, ()&gt; = Yoke::new_always_owned(owned);
<span class="macro">assert_eq!</span>(yoke.get(), <span class="string">"hello"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.into_yokeable" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#524-528">Source</a><h4 class="code-header">pub fn <a href="#method.into_yokeable" class="fn">into_yokeable</a>(self) -&gt; Y</h4></section></summary><div class="docblock"><p>Obtain the yokeable out of a <code>Yoke&lt;Y, ()&gt;</code></p>
<p>For most <code>Yoke</code> types this would be unsafe but its
fine for <code>Yoke&lt;Y, ()&gt;</code> since there are no actual internal
references</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+Option%3CC%3E%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#533-578">Source</a><a href="#impl-Yoke%3CY,+Option%3CC%3E%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;C&gt;&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.new_owned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#558-564">Source</a><h4 class="code-header">pub const fn <a href="#method.new_owned" class="fn">new_owned</a>(yokeable: Y) -&gt; Self</h4></section></summary><div class="docblock"><p>Construct a new <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> from static data. There will be no
references to <code>cart</code> here since <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a>s are <code>'static</code>,
this is good for e.g. constructing fully owned
<a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a>s with no internal borrowing.</p>
<p>This can be paired with [<code>Yoke:: wrap_cart_in_option()</code>] to mix owned
and borrowed data.</p>
<p>If you do not wish to pair this with borrowed data, <a href="struct.Yoke.html#method.new_always_owned" title="associated function yoke::Yoke::new_always_owned"><code>Yoke::new_always_owned()</code></a> can
be used to get a <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> API on always-owned data.</p>
<h5 id="example-5"><a class="doc-anchor" href="#example-5">§</a>Example</h5>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code>
<span class="kw">let </span>owned: Cow&lt;str&gt; = <span class="string">"hello"</span>.to_owned().into();
<span class="comment">// this yoke can be intermingled with actually-borrowed Yokes
</span><span class="kw">let </span>yoke: Yoke&lt;Cow&lt;str&gt;, <span class="prelude-ty">Option</span>&lt;Rc&lt;[u8]&gt;&gt;&gt; = Yoke::new_owned(owned);
<span class="macro">assert_eq!</span>(yoke.get(), <span class="string">"hello"</span>);</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.try_into_yokeable" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#570-577">Source</a><h4 class="code-header">pub fn <a href="#method.try_into_yokeable" class="fn">try_into_yokeable</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Y, Self&gt;</h4></section></summary><div class="docblock"><p>Obtain the yokeable out of a <code>Yoke&lt;Y, Option&lt;C&gt;&gt;</code> if possible.</p>
<p>If the cart is <code>None</code>, this returns <code>Ok</code>, but if the cart is <code>Some</code>,
this returns <code>self</code> as an error.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+Option%3CC%3E%3E-1" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#580-644">Source</a><a href="#impl-Yoke%3CY,+Option%3CC%3E%3E-1" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="cartable_ptr/trait.CartablePointerLike.html" title="trait yoke::cartable_ptr::CartablePointerLike">CartablePointerLike</a>&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/option/enum.Option.html" title="enum core::option::Option">Option</a>&lt;C&gt;&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.convert_cart_into_option_pointer" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#629-643">Source</a><h4 class="code-header">pub fn <a href="#method.convert_cart_into_option_pointer" class="fn">convert_cart_into_option_pointer</a>(
self,
) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="struct" href="cartable_ptr/struct.CartableOptionPointer.html" title="struct yoke::cartable_ptr::CartableOptionPointer">CartableOptionPointer</a>&lt;C&gt;&gt;</h4></section></summary><div class="docblock"><p>Converts a <code>Yoke&lt;Y, Option&lt;C&gt;&gt;</code> to <code>Yoke&lt;Y, CartableOptionPointer&lt;C&gt;&gt;</code>
for better niche optimization when stored as a field.</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::borrow::Cow;
<span class="kw">use </span>yoke::Yoke;
<span class="kw">let </span>yoke: Yoke&lt;Cow&lt;[u8]&gt;, Box&lt;Vec&lt;u8&gt;&gt;&gt; =
Yoke::attach_to_cart(<span class="macro">vec!</span>[<span class="number">10</span>, <span class="number">20</span>, <span class="number">30</span>].into(), |c| c.into());
<span class="kw">let </span>yoke_option = yoke.wrap_cart_in_option();
<span class="kw">let </span>yoke_option_pointer = yoke_option.convert_cart_into_option_pointer();</code></pre></div>
<p>The niche improves stack sizes:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>yoke::Yoke;
<span class="kw">use </span>yoke::cartable_ptr::CartableOptionPointer;
<span class="kw">use </span>std::mem::size_of;
<span class="kw">use </span>std::rc::Rc;
<span class="comment">// The data struct is 6 words:
</span><span class="kw">const </span>W: usize = core::mem::size_of::&lt;usize&gt;();
<span class="macro">assert_eq!</span>(W * <span class="number">6</span>, size_of::&lt;MyDataStruct&gt;());
<span class="comment">// An enum containing the data struct with an `Option&lt;Rc&gt;` cart is 8 words:
</span><span class="kw">enum </span>StaticOrYoke1 {
Static(<span class="kw-2">&amp;</span><span class="lifetime">'static </span>MyDataStruct&lt;<span class="lifetime">'static</span>&gt;),
Yoke(Yoke&lt;MyDataStruct&lt;<span class="lifetime">'static</span>&gt;, <span class="prelude-ty">Option</span>&lt;Rc&lt;String&gt;&gt;&gt;),
}
<span class="macro">assert_eq!</span>(W * <span class="number">8</span>, size_of::&lt;StaticOrYoke1&gt;());
<span class="comment">// When using `CartableOptionPointer``, we need only 7 words for the same behavior:
</span><span class="kw">enum </span>StaticOrYoke2 {
Static(<span class="kw-2">&amp;</span><span class="lifetime">'static </span>MyDataStruct&lt;<span class="lifetime">'static</span>&gt;),
Yoke(Yoke&lt;MyDataStruct&lt;<span class="lifetime">'static</span>&gt;, CartableOptionPointer&lt;Rc&lt;String&gt;&gt;&gt;),
}
<span class="macro">assert_eq!</span>(W * <span class="number">7</span>, size_of::&lt;StaticOrYoke2&gt;());</code></pre></div></div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+CartableOptionPointer%3CC%3E%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#646-659">Source</a><a href="#impl-Yoke%3CY,+CartableOptionPointer%3CC%3E%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="cartable_ptr/trait.CartablePointerLike.html" title="trait yoke::cartable_ptr::CartablePointerLike">CartablePointerLike</a>&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="struct" href="cartable_ptr/struct.CartableOptionPointer.html" title="struct yoke::cartable_ptr::CartableOptionPointer">CartableOptionPointer</a>&lt;C&gt;&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.try_into_yokeable-1" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#652-658">Source</a><h4 class="code-header">pub fn <a href="#method.try_into_yokeable-1" class="fn">try_into_yokeable</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;Y, Self&gt;</h4></section></summary><div class="docblock"><p>Obtain the yokeable out of a <code>Yoke&lt;Y, CartableOptionPointer&lt;C&gt;&gt;</code> if possible.</p>
<p>If the cart is <code>None</code>, this returns <code>Ok</code>, but if the cart is <code>Some</code>,
this returns <code>self</code> as an error.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+C%3E-2" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#751-1096">Source</a><a href="#impl-Yoke%3CY,+C%3E-2" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.map_project" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#819-837">Source</a><h4 class="code-header">pub fn <a href="#method.map_project" class="fn">map_project</a>&lt;P, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,</div></h4></section></summary><div class="docblock"><p>Allows one to “project” a yoke to perform a transformation on the data, potentially
looking at a subfield, and producing a new yoke. This will move cart, and the provided
transformation is only allowed to use data known to be borrowed from the cart.</p>
<p>If producing the new <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>P</code> requires access to the cart in addition to the old
<code>Y</code>, then <a href="struct.Yoke.html#method.map_with_cart" title="method yoke::Yoke::map_with_cart"><code>Yoke::map_with_cart</code></a> can be used if the cart satisfies additional constraints.</p>
<p>The callback takes an additional <code>PhantomData&lt;&amp;()&gt;</code> parameter to anchor lifetimes
(see <a href="https://github.com/rust-lang/rust/issues/86702">#86702</a>) This parameter
should just be ignored in the callback.</p>
<p>This can be used, for example, to transform data from one format to another:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>slice(y: Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str, Rc&lt;[u8]&gt;&gt;) -&gt; Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>[u8], Rc&lt;[u8]&gt;&gt; {
y.map_project(<span class="kw">move </span>|yk, <span class="kw">_</span>| yk.as_bytes())
}</code></pre></div>
<p>This can also be used to create a yoke for a subfield</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// also safely implements Yokeable&lt;'a&gt;
</span><span class="kw">struct </span>Bar&lt;<span class="lifetime">'a</span>&gt; {
string_1: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
string_2: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
}
<span class="kw">fn </span>map_project_string_1(
bar: Yoke&lt;Bar&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;[u8]&gt;&gt;,
) -&gt; Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str, Rc&lt;[u8]&gt;&gt; {
bar.map_project(|bar, <span class="kw">_</span>| bar.string_1)
}
</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.map_project_cloned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#844-863">Source</a><h4 class="code-header">pub fn <a href="#method.map_project_cloned" class="fn">map_project_cloned</a>&lt;'this, P, F&gt;(&amp;'this self, f: F) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a>, however it does not move
<a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Self</code></a> and instead clones the cart (only if the cart is a <a href="trait.CloneableCart.html" title="trait yoke::CloneableCart"><code>CloneableCart</code></a>)</p>
<p>This is a bit more efficient than cloning the <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> and then calling <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a>
because then it will not clone fields that are going to be discarded.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_project" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#924-942">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_project" class="fn">try_map_project</a>&lt;P, F, E&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a>, however it can also bubble up an error
from the callback.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">fn </span>slice(
y: Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>[u8], Rc&lt;[u8]&gt;&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str, Rc&lt;[u8]&gt;&gt;, Utf8Error&gt; {
y.try_map_project(<span class="kw">move </span>|bytes, <span class="kw">_</span>| str::from_utf8(bytes))
}</code></pre></div>
<p>This can also be used to create a yoke for a subfield</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// also safely implements Yokeable&lt;'a&gt;
</span><span class="kw">struct </span>Bar&lt;<span class="lifetime">'a</span>&gt; {
bytes_1: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>[u8],
string_2: <span class="kw-2">&amp;</span><span class="lifetime">'a </span>str,
}
<span class="kw">fn </span>map_project_string_1(
bar: Yoke&lt;Bar&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;[u8]&gt;&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>str, Rc&lt;[u8]&gt;&gt;, Utf8Error&gt; {
bar.try_map_project(|bar, <span class="kw">_</span>| str::from_utf8(bar.bytes_1))
}
</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_project_cloned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#949-968">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_project_cloned" class="fn">try_map_project_cloned</a>&lt;'this, P, F, E&gt;(
&amp;'this self,
f: F,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.try_map_project" title="method yoke::Yoke::try_map_project"><code>Yoke::try_map_project</code></a>, however it does not move
<a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Self</code></a> and instead clones the cart (only if the cart is a <a href="trait.CloneableCart.html" title="trait yoke::CloneableCart"><code>CloneableCart</code></a>)</p>
<p>This is a bit more efficient than cloning the <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> and then calling <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a>
because then it will not clone fields that are going to be discarded.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_project_with_explicit_capture" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#974-1000">Source</a><h4 class="code-header">pub fn <a href="#method.map_project_with_explicit_capture" class="fn">map_project_with_explicit_capture</a>&lt;P, T&gt;(
self,
capture: T,
f: for&lt;'a&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(_: &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, capture: T, _: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a>, but it works around older versions
of Rust not being able to use <code>FnOnce</code> by using an explicit capture input.
See <a href="https://github.com/unicode-org/icu4x/issues/1061">#1061</a>.</p>
<p>See the docs of <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a> for how this works.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.map_project_cloned_with_explicit_capture" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1007-1030">Source</a><h4 class="code-header">pub fn <a href="#method.map_project_cloned_with_explicit_capture" class="fn">map_project_cloned_with_explicit_capture</a>&lt;'this, P, T&gt;(
&amp;'this self,
capture: T,
f: for&lt;'a&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(_: &amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, capture: T, _: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_project_cloned" title="method yoke::Yoke::map_project_cloned"><code>Yoke::map_project_cloned</code></a>, but it works around older versions
of Rust not being able to use <code>FnOnce</code> by using an explicit capture input.
See <a href="https://github.com/unicode-org/icu4x/issues/1061">#1061</a>.</p>
<p>See the docs of <a href="struct.Yoke.html#method.map_project_cloned" title="method yoke::Yoke::map_project_cloned"><code>Yoke::map_project_cloned</code></a> for how this works.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_project_with_explicit_capture" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1038-1064">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_project_with_explicit_capture" class="fn">try_map_project_with_explicit_capture</a>&lt;P, T, E&gt;(
self,
capture: T,
f: for&lt;'a&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(_: &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, capture: T, _: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.try_map_project" title="method yoke::Yoke::try_map_project"><code>Yoke::try_map_project</code></a>, but it works around older versions
of Rust not being able to use <code>FnOnce</code> by using an explicit capture input.
See <a href="https://github.com/unicode-org/icu4x/issues/1061">#1061</a>.</p>
<p>See the docs of <a href="struct.Yoke.html#method.try_map_project" title="method yoke::Yoke::try_map_project"><code>Yoke::try_map_project</code></a> for how this works.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_project_cloned_with_explicit_capture" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1072-1095">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_project_cloned_with_explicit_capture" class="fn">try_map_project_cloned_with_explicit_capture</a>&lt;'this, P, T, E&gt;(
&amp;'this self,
capture: T,
f: for&lt;'a&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.fn.html">fn</a>(_: &amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, capture: T, _: <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/marker/struct.PhantomData.html" title="struct core::marker::PhantomData">PhantomData</a>&lt;&amp;'a <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.unit.html">()</a>&gt;) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.try_map_project_cloned" title="method yoke::Yoke::try_map_project_cloned"><code>Yoke::try_map_project_cloned</code></a>, but it works around older versions
of Rust not being able to use <code>FnOnce</code> by using an explicit capture input.
See <a href="https://github.com/unicode-org/icu4x/issues/1061">#1061</a>.</p>
<p>See the docs of <a href="struct.Yoke.html#method.try_map_project_cloned" title="method yoke::Yoke::try_map_project_cloned"><code>Yoke::try_map_project_cloned</code></a> for how this works.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+C%3E-3" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#1098-1330">Source</a><a href="#impl-Yoke%3CY,+C%3E-3" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="../stable_deref_trait/trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a>&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.map_with_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1198-1220">Source</a><h4 class="code-header">pub fn <a href="#method.map_with_cart" class="fn">map_with_cart</a>&lt;P, F&gt;(self, f: F) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, &amp;'a &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>Allows one to produce a new yoke from both the cart and the old yoke. This will move the
cart, and the provided transformation is only allowed to use data known to be borrowed from
the cart.</p>
<p>If access to the old <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>Y</code> is sufficient to produce the new <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>P</code>,
then <a href="struct.Yoke.html#method.map_project" title="method yoke::Yoke::map_project"><code>Yoke::map_project</code></a> should be preferred, as <code>map_with_cart</code> places additional
constraints on the cart.</p>
<p>This can be used, for example, to transform data between two formats, one of which contains
more data:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Both structs have `first_line`, which won't need to be recomputed in `map_with_cart`.
// They also safely implement `Yokeable&lt;'a&gt;`
</span><span class="kw">struct </span>Foo&lt;<span class="lifetime">'a</span>&gt; {
first_line: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str&gt;,
}
<span class="kw">struct </span>Bar&lt;<span class="lifetime">'a</span>&gt; {
first_line: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str&gt;,
last_line: <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str&gt;,
}
<span class="kw">fn </span>foo_to_bar(
foo: Yoke&lt;Foo&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;str&gt;&gt;,
) -&gt; Yoke&lt;Bar&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;str&gt;&gt; {
foo.map_with_cart(|foo, cart| {
Bar {
first_line: foo.first_line,
last_line: cart.lines().next_back(),
}
})
}
<span class="kw">fn </span>bar_to_foo(
bar: Yoke&lt;Bar&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;str&gt;&gt;,
) -&gt; Yoke&lt;Foo&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;str&gt;&gt; {
bar.map_project(|bar, <span class="kw">_</span>| {
Foo {
first_line: bar.first_line,
}
})
}
</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.map_with_cart_cloned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1231-1251">Source</a><h4 class="code-header">pub fn <a href="#method.map_with_cart_cloned" class="fn">map_with_cart_cloned</a>&lt;'this, P, F&gt;(&amp;'this self, f: F) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, &amp;'a &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; &lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_with_cart" title="method yoke::Yoke::map_with_cart"><code>Yoke::map_with_cart</code></a>, but it does not move <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Self</code></a> and instead
clones the cart (only if the cart is a <a href="trait.CloneableCart.html" title="trait yoke::CloneableCart"><code>CloneableCart</code></a>).</p>
<p>This is a bit more efficient than cloning the <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> and then calling
<a href="struct.Yoke.html#method.map_with_cart" title="method yoke::Yoke::map_with_cart"><code>Yoke::map_with_cart</code></a> because it will not clone fields that are going to be discarded.</p>
<p>If access to the old <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>Y</code> is sufficient to produce the new <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>P</code>,
then <a href="struct.Yoke.html#method.map_project_cloned" title="method yoke::Yoke::map_project_cloned"><code>Yoke::map_project_cloned</code></a> should be preferred, as <code>map_with_cart_cloned</code> places
additional constraints on the cart.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_with_cart" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1276-1298">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_with_cart" class="fn">try_map_with_cart</a>&lt;P, F, E&gt;(self, f: F) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, &amp;'a &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.map_with_cart" title="method yoke::Yoke::map_with_cart"><code>Yoke::map_with_cart</code></a>, but it can also bubble up an error
from the callback.</p>
<p>If access to the old <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>Y</code> is sufficient to produce the new <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>P</code>,
then <a href="struct.Yoke.html#method.try_map_project" title="method yoke::Yoke::try_map_project"><code>Yoke::try_map_project</code></a> should be preferred, as <code>try_map_with_cart</code> places
additional constraints on the cart.</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="comment">// Implements `Yokeable`
</span><span class="kw">type </span>P&lt;<span class="lifetime">'a</span>&gt; = (<span class="kw-2">&amp;</span><span class="lifetime">'a </span>str, <span class="prelude-ty">Option</span>&lt;<span class="kw-2">&amp;</span><span class="lifetime">'a </span>u8&gt;);
<span class="kw">fn </span>slice(
y: Yoke&lt;<span class="kw-2">&amp;</span><span class="lifetime">'static </span>[u8], Rc&lt;[u8]&gt;&gt;,
) -&gt; <span class="prelude-ty">Result</span>&lt;Yoke&lt;P&lt;<span class="lifetime">'static</span>&gt;, Rc&lt;[u8]&gt;&gt;, Utf8Error&gt; {
y.try_map_with_cart(<span class="kw">move </span>|bytes, cart| {
<span class="prelude-val">Ok</span>((str::from_utf8(bytes)<span class="question-mark">?</span>, bytes.first()))
})
}</code></pre></div></div></details><details class="toggle method-toggle" open><summary><section id="method.try_map_with_cart_cloned" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1309-1329">Source</a><h4 class="code-header">pub fn <a href="#method.try_map_with_cart_cloned" class="fn">try_map_with_cart_cloned</a>&lt;'this, P, F, E&gt;(
&amp;'this self,
f: F,
) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;<a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;P, C&gt;, E&gt;<div class="where">where
P: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>,
F: for&lt;'a&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/function/trait.FnOnce.html" title="trait core::ops::function::FnOnce">FnOnce</a>(&amp;'this &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, &amp;'a &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;&lt;P as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>, E&gt;,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h4></section></summary><div class="docblock"><p>This is similar to <a href="struct.Yoke.html#method.try_map_with_cart" title="method yoke::Yoke::try_map_with_cart"><code>Yoke::try_map_with_cart</code></a>, but it does not move <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Self</code></a> and instead
clones the cart (only if the cart is a <a href="trait.CloneableCart.html" title="trait yoke::CloneableCart"><code>CloneableCart</code></a>).</p>
<p>This is a bit more efficient than cloning the <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a> and then calling
<a href="struct.Yoke.html#method.try_map_with_cart" title="method yoke::Yoke::try_map_with_cart"><code>Yoke::try_map_with_cart</code></a> because it will not clone fields that are going to be discarded.</p>
<p>If access to the old <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>Y</code> is sufficient to producethe new <a href="trait.Yokeable.html" title="trait yoke::Yokeable"><code>Yokeable</code></a> <code>P</code>,
then <a href="struct.Yoke.html#method.try_map_project_cloned" title="method yoke::Yoke::try_map_project_cloned"><code>Yoke::try_map_project_cloned</code></a> should be preferred, as <code>try_map_with_cart_cloned</code>
places additional constraints on the cart.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+C%3E-4" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#1494-1517">Source</a><a href="#impl-Yoke%3CY,+C%3E-4" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;</h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.wrap_cart_in_either_a" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1502-1505">Source</a><h4 class="code-header">pub fn <a href="#method.wrap_cart_in_either_a" class="fn">wrap_cart_in_either_a</a>&lt;B&gt;(self) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="enum" href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart">EitherCart</a>&lt;C, B&gt;&gt;</h4></section></summary><div class="docblock"><p>Helper function allowing one to wrap the cart type <code>C</code> in an <a href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart"><code>EitherCart</code></a>.</p>
<p>This function wraps the cart into the <code>A</code> variant. To wrap it into the
<code>B</code> variant, use <a href="struct.Yoke.html#method.wrap_cart_in_either_b" title="method yoke::Yoke::wrap_cart_in_either_b"><code>Self::wrap_cart_in_either_b()</code></a>.</p>
<p>For an example, see <a href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart"><code>EitherCart</code></a>.</p>
</div></details><details class="toggle method-toggle" open><summary><section id="method.wrap_cart_in_either_b" class="method"><a class="src rightside" href="../src/yoke/yoke.rs.html#1513-1516">Source</a><h4 class="code-header">pub fn <a href="#method.wrap_cart_in_either_b" class="fn">wrap_cart_in_either_b</a>&lt;A&gt;(self) -&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, <a class="enum" href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart">EitherCart</a>&lt;A, C&gt;&gt;</h4></section></summary><div class="docblock"><p>Helper function allowing one to wrap the cart type <code>C</code> in an <a href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart"><code>EitherCart</code></a>.</p>
<p>This function wraps the cart into the <code>B</code> variant. To wrap it into the
<code>A</code> variant, use <a href="struct.Yoke.html#method.wrap_cart_in_either_a" title="method yoke::Yoke::wrap_cart_in_either_a"><code>Self::wrap_cart_in_either_a()</code></a>.</p>
<p>For an example, see <a href="either/enum.EitherCart.html" title="enum yoke::either::EitherCart"><code>EitherCart</code></a>.</p>
</div></details></div></details><details class="toggle implementors-toggle" open><summary><section id="impl-Yoke%3CY,+C%3E-5" class="impl"><a class="src rightside" href="../src/yoke/zero_from.rs.html#13-44">Source</a><a href="#impl-Yoke%3CY,+C%3E-5" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;,
for&lt;'a&gt; &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>: <a class="trait" href="../zerofrom/zero_from/trait.ZeroFrom.html" title="trait zerofrom::zero_from::ZeroFrom">ZeroFrom</a>&lt;'a, &lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>&gt;,
C: <a class="trait" href="../stable_deref_trait/trait.StableDeref.html" title="trait stable_deref_trait::StableDeref">StableDeref</a> + <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>,
&lt;C as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html" title="trait core::ops::deref::Deref">Deref</a>&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/ops/deref/trait.Deref.html#associatedtype.Target" title="type core::ops::deref::Deref::Target">Target</a>: 'static,</div></h3></section></summary><div class="impl-items"><details class="toggle method-toggle" open><summary><section id="method.attach_to_zero_copy_cart" class="method"><a class="src rightside" href="../src/yoke/zero_from.rs.html#41-43">Source</a><h4 class="code-header">pub fn <a href="#method.attach_to_zero_copy_cart" class="fn">attach_to_zero_copy_cart</a>(cart: C) -&gt; Self</h4></section></summary><div class="docblock"><p>Construct a <a href="struct.Yoke.html" title="struct yoke::Yoke"><code>Yoke</code></a><code>&lt;Y, C&gt;</code> from a cart implementing <code>StableDeref</code> by zero-copy cloning
the cart to <code>Y</code> and then yokeing that object to the cart.</p>
<p>The type <code>Y</code> must implement <a href="../zerofrom/zero_from/trait.ZeroFrom.html" title="trait zerofrom::zero_from::ZeroFrom"><code>ZeroFrom</code></a><code>&lt;C::Target&gt;</code>. This trait is auto-implemented
on many common types and can be custom implemented or derived in order to make it easier
to construct a <code>Yoke</code>.</p>
<h5 id="example-6"><a class="doc-anchor" href="#example-6">§</a>Example</h5>
<p>Attach to a cart:</p>
<div class="example-wrap"><pre class="rust rust-example-rendered"><code><span class="kw">use </span>std::borrow::Cow;
<span class="kw">use </span>yoke::Yoke;
<span class="kw">let </span>yoke = Yoke::&lt;Cow&lt;<span class="lifetime">'static</span>, str&gt;, String&gt;::attach_to_zero_copy_cart(
<span class="string">"demo"</span>.to_owned(),
);
<span class="macro">assert_eq!</span>(<span class="string">"demo"</span>, yoke.get());</code></pre></div></div></details></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-Clone-for-Yoke%3CY,+C%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#701-717">Source</a><a href="#impl-Clone-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="trait.CloneableCart.html" title="trait yoke::CloneableCart">CloneableCart</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
for&lt;'a&gt; &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html" title="trait core::clone::Clone">Clone</a>,</div></h3><div class="docblock"><p>Clone requires that the cart type <code>C</code> derefs to the same address after it is cloned. This works for
Rc, Arc, and &amp;a T.</p>
</div></section></summary><div class="docblock"><p>For other cart types, clone <code>.backing_cart()</code> and re-use <code>.attach_to_cart()</code>; however, doing
so may lose mutations performed via <code>.with_mut()</code>.</p>
<p>Cloning a <code>Yoke</code> is often a cheap operation requiring no heap allocations, in much the same
way that cloning an <code>Rc</code> is a cheap operation. However, if the <code>yokeable</code> contains owned data
(e.g., from <code>.with_mut()</code>), that data will need to be cloned.</p>
</div><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/yoke/yoke.rs.html#705-716">Source</a><a href="#method.clone" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html#tymethod.clone" class="fn">clone</a>(&amp;self) -&gt; Self</h4></section></summary><div class='docblock'>Returns a duplicate of the value. <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/clone.rs.html#245-247">Source</a></span><a href="#method.clone_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/clone/trait.Clone.html#method.clone_from" class="fn">clone_from</a>(&amp;mut self, source: &amp;Self)</h4></section></summary><div class='docblock'>Performs copy-assignment from <code>source</code>. <a href="https://doc.rust-lang.org/1.93.1/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-Yoke%3CY,+C%3E" class="impl"><a class="src rightside" href="../src/yoke/yoke.rs.html#97-107">Source</a><a href="#impl-Debug-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y: for&lt;'a&gt; <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;, C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
for&lt;'a&gt; &lt;Y as <a class="trait" href="trait.Yokeable.html" title="trait yoke::Yokeable">Yokeable</a>&lt;'a&gt;&gt;::<a class="associatedtype" href="trait.Yokeable.html#associatedtype.Output" title="type yoke::Yokeable::Output">Output</a>: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html" title="trait core::fmt::Debug">Debug</a>,</div></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/yoke/yoke.rs.html#101-106">Source</a><a href="#method.fmt" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt" class="fn">fmt</a>(&amp;self, f: &amp;mut <a class="struct" href="https://doc.rust-lang.org/1.93.1/core/fmt/struct.Formatter.html" title="struct core::fmt::Formatter">Formatter</a>&lt;'_&gt;) -&gt; <a class="type" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/core/fmt/trait.Debug.html#tymethod.fmt">Read more</a></div></details></div></details></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-Yoke%3CY,+C%3E" class="impl"><a href="#impl-Freeze-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Freeze.html" title="trait core::marker::Freeze">Freeze</a>,</div></h3></section><section id="impl-RefUnwindSafe-for-Yoke%3CY,+C%3E" class="impl"><a href="#impl-RefUnwindSafe-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.RefUnwindSafe.html" title="trait core::panic::unwind_safe::RefUnwindSafe">RefUnwindSafe</a>,</div></h3></section><section id="impl-Send-for-Yoke%3CY,+C%3E" class="impl"><a href="#impl-Send-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Send.html" title="trait core::marker::Send">Send</a>,</div></h3></section><section id="impl-Sync-for-Yoke%3CY,+C%3E" class="impl"><a href="#impl-Sync-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Sync.html" title="trait core::marker::Sync">Sync</a>,</div></h3></section><section id="impl-Unpin-for-Yoke%3CY,+C%3E" class="impl"><a href="#impl-Unpin-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/marker/trait.Unpin.html" title="trait core::marker::Unpin">Unpin</a>,</div></h3></section><section id="impl-UnwindSafe-for-Yoke%3CY,+C%3E" class="impl"><a href="#impl-UnwindSafe-for-Yoke%3CY,+C%3E" class="anchor">§</a><h3 class="code-header">impl&lt;Y, C&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a> for <a class="struct" href="struct.Yoke.html" title="struct yoke::Yoke">Yoke</a>&lt;Y, C&gt;<div class="where">where
C: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,
Y: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/panic/unwind_safe/trait.UnwindSafe.html" title="trait core::panic::unwind_safe::UnwindSafe">UnwindSafe</a>,</div></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/1.93.1/src/core/any.rs.html#138">Source</a><a href="#impl-Any-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/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/1.93.1/src/core/any.rs.html#139">Source</a><a href="#method.type_id" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/any/trait.Any.html#tymethod.type_id" class="fn">type_id</a>(&amp;self) -&gt; <a class="struct" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/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/1.93.1/src/core/borrow.rs.html#212">Source</a><a href="#impl-Borrow%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html" title="trait core::borrow::Borrow">Borrow</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/borrow.rs.html#214">Source</a><a href="#method.borrow" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.Borrow.html#tymethod.borrow" class="fn">borrow</a>(&amp;self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;T</a></h4></section></summary><div class='docblock'>Immutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/borrow.rs.html#221">Source</a><a href="#impl-BorrowMut%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html" title="trait core::borrow::BorrowMut">BorrowMut</a>&lt;T&gt; for T<div class="where">where
T: ?<a class="trait" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/borrow.rs.html#222">Source</a><a href="#method.borrow_mut" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/borrow/trait.BorrowMut.html#tymethod.borrow_mut" class="fn">borrow_mut</a>(&amp;mut self) -&gt; <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;mut T</a></h4></section></summary><div class='docblock'>Mutably borrows from an owned value. <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/clone.rs.html#547">Source</a><a href="#impl-CloneToUninit-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/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/1.93.1/src/core/clone.rs.html#549">Source</a><a href="#method.clone_to_uninit" class="anchor">§</a><h4 class="code-header">unsafe fn <a href="https://doc.rust-lang.org/1.93.1/core/clone/trait.CloneToUninit.html#tymethod.clone_to_uninit" class="fn">clone_to_uninit</a>(&amp;self, dest: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.pointer.html">*mut </a><a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.u8.html">u8</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>dest</code>. <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/convert/mod.rs.html#785">Source</a><a href="#impl-From%3CT%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; 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/1.93.1/src/core/convert/mod.rs.html#788">Source</a><a href="#method.from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html#tymethod.from" class="fn">from</a>(t: T) -&gt; 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/1.93.1/src/core/convert/mod.rs.html#767-769">Source</a><a href="#impl-Into%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt;,</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/1.93.1/src/core/convert/mod.rs.html#777">Source</a><a href="#method.into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html#tymethod.into" class="fn">into</a>(self) -&gt; 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/1.93.1/core/convert/trait.From.html" title="trait core::convert::From">From</a>&lt;T&gt; for U</code> chooses to do.</p>
</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/1.93.1/src/alloc/borrow.rs.html#85-87">Source</a><a href="#impl-ToOwned-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/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 class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/alloc/borrow.rs.html#89">Source</a><a href="#associatedtype.Owned" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/alloc/borrow.rs.html#90">Source</a><a href="#method.to_owned" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/alloc/borrow/trait.ToOwned.html#tymethod.to_owned" class="fn">to_owned</a>(&amp;self) -&gt; T</h4></section></summary><div class='docblock'>Creates owned data from borrowed data, usually by cloning. <a href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/alloc/borrow.rs.html#94">Source</a><a href="#method.clone_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/alloc/borrow/trait.ToOwned.html#method.clone_into" class="fn">clone_into</a>(&amp;self, target: <a class="primitive" href="https://doc.rust-lang.org/1.93.1/std/primitive.reference.html">&amp;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/1.93.1/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/1.93.1/src/core/convert/mod.rs.html#827-829">Source</a><a href="#impl-TryFrom%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.Into.html" title="trait core::convert::Into">Into</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error-1" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#831">Source</a><a href="#associatedtype.Error-1" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" class="associatedtype">Error</a> = <a class="enum" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/convert/mod.rs.html#834">Source</a><a href="#method.try_from" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#tymethod.try_from" class="fn">try_from</a>(value: U) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;T, &lt;T as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;U&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</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/1.93.1/src/core/convert/mod.rs.html#811-813">Source</a><a href="#impl-TryInto%3CU%3E-for-T" class="anchor">§</a><h3 class="code-header">impl&lt;T, U&gt; <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html" title="trait core::convert::TryInto">TryInto</a>&lt;U&gt; for T<div class="where">where
U: <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;,</div></h3></section></summary><div class="impl-items"><details class="toggle" open><summary><section id="associatedtype.Error" class="associatedtype trait-impl"><a class="src rightside" href="https://doc.rust-lang.org/1.93.1/src/core/convert/mod.rs.html#815">Source</a><a href="#associatedtype.Error" class="anchor">§</a><h4 class="code-header">type <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#associatedtype.Error" class="associatedtype">Error</a> = &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/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/1.93.1/src/core/convert/mod.rs.html#818">Source</a><a href="#method.try_into" class="anchor">§</a><h4 class="code-header">fn <a href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryInto.html#tymethod.try_into" class="fn">try_into</a>(self) -&gt; <a class="enum" href="https://doc.rust-lang.org/1.93.1/core/result/enum.Result.html" title="enum core::result::Result">Result</a>&lt;U, &lt;U as <a class="trait" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html" title="trait core::convert::TryFrom">TryFrom</a>&lt;T&gt;&gt;::<a class="associatedtype" href="https://doc.rust-lang.org/1.93.1/core/convert/trait.TryFrom.html#associatedtype.Error" title="type core::convert::TryFrom::Error">Error</a>&gt;</h4></section></summary><div class='docblock'>Performs the conversion.</div></details></div></details></div></section></div></main></body></html>