aptos-move/framework/move-stdlib/doc/mem.md
<a id="0x1_mem"></a>
0x1::memModule with methods for safe memory manipulation.
<pre><code></code></pre><a id="0x1_mem_swap"></a>
swapSwap contents of two passed mutable references.
Move prevents from having two mutable references to the same value, so <code>left</code> and <code>right</code> references are always distinct.
<pre><code><b>public</b> <b>fun</b> <a href="mem.md#0x1_mem_swap">swap</a><T>(left: &<b>mut</b> T, right: &<b>mut</b> T) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="mem.md#0x1_mem_swap">swap</a><T>(left: &<b>mut</b> T, right: &<b>mut</b> T); </code></pre> </details><a id="0x1_mem_replace"></a>
replaceReplace the value reference points to with the given new value, and return the value it had before.
<pre><code><b>public</b> <b>fun</b> <a href="mem.md#0x1_mem_replace">replace</a><T>(ref: &<b>mut</b> T, new: T): T </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="mem.md#0x1_mem_replace">replace</a><T>(ref: &<b>mut</b> T, new: T): T { <a href="mem.md#0x1_mem_swap">swap</a>(ref, &<b>mut</b> new); new } </code></pre> </details><a id="@Specification_0"></a>
<a id="@Specification_0_swap"></a>
swap<a id="@Specification_0_replace"></a>
replace