aptos-move/framework/move-stdlib/doc/option.md
<a id="0x1_option"></a>
0x1::optionThis module defines the Option type and its methods to represent and handle an optional value.
Optionnonesomefrom_vecis_noneis_somecontainsborrowborrow_with_defaultget_with_defaultfillextractborrow_mutswapswap_or_filldestroy_with_defaultdestroy_somedestroy_noneto_vecfor_eachfor_each_reffor_each_mutfoldmapmap_reffilteranydestroynonesomefrom_vecis_noneis_somecontainsborrowborrow_with_defaultget_with_defaultfillextractborrow_mutswapswap_or_filldestroy_with_defaultdestroy_somedestroy_noneto_vec<a id="0x1_option_Option"></a>
OptionAbstraction of a value that may or may not be present.
<pre><code>enum <a href="option.md#0x1_option_Option">Option</a><Element> <b>has</b> <b>copy</b>, drop, store </code></pre> <details> <summary>Variants</summary> <details> <summary>None</summary> <details> <summary>Fields</summary> <dl> </dl> </details> </details> <details> <summary>Some</summary> <details> <summary>Fields</summary> <dl> <dt> <code>e: Element</code> </dt> <dd> </dd> </dl> </details> </details> </details><a id="@Constants_0"></a>
<a id="0x1_option_EOPTION_IS_SET"></a>
The <code><a href="option.md#0x1_option_Option">Option</a></code> is in an invalid state for the operation attempted. The <code><a href="option.md#0x1_option_Option">Option</a></code> is <code>Some</code> while it should be <code>None</code>.
<pre><code><b>const</b> <a href="option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a>: u64 = 262144; </code></pre><a id="0x1_option_EOPTION_NOT_SET"></a>
The <code><a href="option.md#0x1_option_Option">Option</a></code> is in an invalid state for the operation attempted. The <code><a href="option.md#0x1_option_Option">Option</a></code> is <code>None</code> while it should be <code>Some</code>.
<pre><code><b>const</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>: u64 = 262145; </code></pre><a id="0x1_option_EOPTION_VEC_TOO_LONG"></a>
Cannot construct an option from a vector with 2 or more elements.
<pre><code><b>const</b> <a href="option.md#0x1_option_EOPTION_VEC_TOO_LONG">EOPTION_VEC_TOO_LONG</a>: u64 = 262146; </code></pre><a id="0x1_option_none"></a>
noneReturn an empty <code><a href="option.md#0x1_option_Option">Option</a></code>
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_none">none</a><Element>(): <a href="option.md#0x1_option_Option">option::Option</a><Element> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_none">none</a><Element>(): <a href="option.md#0x1_option_Option">Option</a><Element> { Option::None } </code></pre> </details><a id="0x1_option_some"></a>
someReturn an <code><a href="option.md#0x1_option_Option">Option</a></code> containing <code>e</code>
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_some">some</a><Element>(e: Element): <a href="option.md#0x1_option_Option">option::Option</a><Element> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_some">some</a><Element>(e: Element): <a href="option.md#0x1_option_Option">Option</a><Element> { Option::Some { e } } </code></pre> </details><a id="0x1_option_from_vec"></a>
from_vec<a id="0x1_option_is_none"></a>
is_noneReturn true if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_is_none">is_none</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>): bool </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_is_none">is_none</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>): bool { self is Option::None<Element> } </code></pre> </details><a id="0x1_option_is_some"></a>
is_someReturn true if <code>self</code> holds a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_is_some">is_some</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>): bool </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_is_some">is_some</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>): bool { self is Option::Some<Element> } </code></pre> </details><a id="0x1_option_contains"></a>
containsReturn true if the value in <code>self</code> is equal to <code>e_ref</code> Always returns <code><b>false</b></code> if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_contains">contains</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, e_ref: &Element): bool </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_contains">contains</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>, e_ref: &Element): bool { <b>if</b> (self is Option::None<Element>) { <b>false</b> } <b>else</b> { &self.e == e_ref } } </code></pre> </details><a id="0x1_option_borrow"></a>
borrowReturn an immutable reference to the value inside <code>self</code> Aborts if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow">borrow</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>): &Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow">borrow</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>): &Element { <b>if</b> (self is Option::None<Element>) { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> } <b>else</b> { &self.e } } </code></pre> </details><a id="0x1_option_borrow_with_default"></a>
borrow_with_defaultReturn a reference to the value inside <code>self</code> if it holds one Return <code>default_ref</code> if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow_with_default">borrow_with_default</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, default_ref: &Element): &Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow_with_default">borrow_with_default</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>, default_ref: &Element): &Element { match (self) { Option::None => default_ref, Option::Some { e } => e, } } </code></pre> </details><a id="0x1_option_get_with_default"></a>
get_with_defaultReturn the value inside <code>self</code> if it holds one Return <code>default</code> if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_get_with_default">get_with_default</a><Element: <b>copy</b>, drop>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, default: Element): Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_get_with_default">get_with_default</a><Element: <b>copy</b> + drop>( self: &<a href="option.md#0x1_option_Option">Option</a><Element>, default: Element, ): Element { match (self) { Option::None => default, Option::Some { e } => *e, } } </code></pre> </details><a id="0x1_option_fill"></a>
fillConvert the none option <code>self</code> to a some option by adding <code>e</code>. Aborts if <code>self</code> already holds a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_fill">fill</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>, e: Element) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_fill">fill</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>, e: Element) { <b>let</b> <b>old</b> = <a href="mem.md#0x1_mem_replace">mem::replace</a>(self, Option::Some { e }); match (<b>old</b>) { Option::None => {}, Option::Some { e: _ } => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a> }, } } </code></pre> </details><a id="0x1_option_extract"></a>
extractConvert a <code>some</code> option to a <code>none</code> by removing and returning the value stored inside <code>self</code> Aborts if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_extract">extract</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>): Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_extract">extract</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>): Element { <b>let</b> inner = <a href="mem.md#0x1_mem_replace">mem::replace</a>(self, Option::None); match (inner) { Option::Some { e } => e, Option::None => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> }, } } </code></pre> </details><a id="0x1_option_borrow_mut"></a>
borrow_mutReturn a mutable reference to the value inside <code>self</code> Aborts if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow_mut">borrow_mut</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>): &<b>mut</b> Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_borrow_mut">borrow_mut</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>): &<b>mut</b> Element { match (self) { Option::None => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> }, Option::Some { e } => e, } } </code></pre> </details><a id="0x1_option_swap"></a>
swapSwap the old value inside <code>self</code> with <code>e</code> and return the old value Aborts if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_swap">swap</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>, el: Element): Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_swap">swap</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>, el: Element): Element { match (self) { Option::None => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> }, Option::Some { e } => { <a href="mem.md#0x1_mem_replace">mem::replace</a>(e, el) }, } } </code></pre> </details><a id="0x1_option_swap_or_fill"></a>
swap_or_fillSwap the old value inside <code>self</code> with <code>e</code> and return the old value; or if there is no old value, fill it with <code>e</code>. Different from swap(), swap_or_fill() allows for <code>self</code> not holding a value.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_swap_or_fill">swap_or_fill</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>, e: Element): <a href="option.md#0x1_option_Option">option::Option</a><Element> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_swap_or_fill">swap_or_fill</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>, e: Element): <a href="option.md#0x1_option_Option">Option</a><Element> { <a href="mem.md#0x1_mem_replace">mem::replace</a>(self, Option::Some { e }) } </code></pre> </details><a id="0x1_option_destroy_with_default"></a>
destroy_with_defaultDestroys <code>self.</code> If <code>self</code> holds a value, return it. Returns <code>default</code> otherwise
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_with_default">destroy_with_default</a><Element: drop>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, default: Element): Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_with_default">destroy_with_default</a><Element: drop>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, default: Element): Element { match (self) { Option::None => default, Option::Some { e } => e, } } </code></pre> </details><a id="0x1_option_destroy_some"></a>
destroy_someUnpack <code>self</code> and return its contents Aborts if <code>self</code> does not hold a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_some">destroy_some</a><Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>): Element </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_some">destroy_some</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>): Element { match (self) { Option::None => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> }, Option::Some { e } => e, } } </code></pre> </details><a id="0x1_option_destroy_none"></a>
destroy_noneUnpack <code>self</code> Aborts if <code>self</code> holds a value
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_none">destroy_none</a><Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy_none">destroy_none</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>) { match (self) { Option::None => {}, Option::Some { e: _ } => { <b>abort</b> <a href="option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a> }, } } </code></pre> </details><a id="0x1_option_to_vec"></a>
to_vecConvert <code>self</code> into a vector of length 1 if it is <code>Some</code>, and an empty vector otherwise
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_to_vec">to_vec</a><Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>): <a href="vector.md#0x1_vector">vector</a><Element> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_to_vec">to_vec</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>): <a href="vector.md#0x1_vector">vector</a><Element> { match (self) { Option::None => <a href="vector.md#0x1_vector_empty">vector::empty</a>(), Option::Some { e } => <a href="vector.md#0x1_vector_singleton">vector::singleton</a>(e), } } </code></pre> </details><a id="0x1_option_for_each"></a>
for_eachApply the function to the optional element, consuming it. Does nothing if no value present.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_for_each">for_each</a><Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |Element|) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_for_each">for_each</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, f: |Element|) { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { f(self.<a href="option.md#0x1_option_destroy_some">destroy_some</a>()) } <b>else</b> { self.<a href="option.md#0x1_option_destroy_none">destroy_none</a>() } } </code></pre> </details><a id="0x1_option_for_each_ref"></a>
for_each_refApply the function to the optional element reference. Does nothing if no value present.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_for_each_ref">for_each_ref</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |&Element|) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_for_each_ref">for_each_ref</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>, f: |&Element|) { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { f(self.<a href="option.md#0x1_option_borrow">borrow</a>()) } } </code></pre> </details><a id="0x1_option_for_each_mut"></a>
for_each_mutApply the function to the optional element reference. Does nothing if no value present.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_for_each_mut">for_each_mut</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |&<b>mut</b> Element|) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_for_each_mut">for_each_mut</a><Element>(self: &<b>mut</b> <a href="option.md#0x1_option_Option">Option</a><Element>, f: |&<b>mut</b> Element|) { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { f(self.<a href="option.md#0x1_option_borrow_mut">borrow_mut</a>()) } } </code></pre> </details><a id="0x1_option_fold"></a>
foldFolds the function over the optional element.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_fold">fold</a><Accumulator, Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, init: Accumulator, f: |Accumulator, Element|Accumulator): Accumulator </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_fold">fold</a><Accumulator, Element>( self: <a href="option.md#0x1_option_Option">Option</a><Element>, init: Accumulator, f: |Accumulator,Element|Accumulator ): Accumulator { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { f(init, self.<a href="option.md#0x1_option_destroy_some">destroy_some</a>()) } <b>else</b> { self.<a href="option.md#0x1_option_destroy_none">destroy_none</a>(); init } } </code></pre> </details><a id="0x1_option_map"></a>
mapMaps the content of an option.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_map">map</a><Element, OtherElement>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |Element|OtherElement): <a href="option.md#0x1_option_Option">option::Option</a><OtherElement> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_map">map</a><Element, OtherElement>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, f: |Element|OtherElement): <a href="option.md#0x1_option_Option">Option</a><OtherElement> { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { <a href="option.md#0x1_option_some">some</a>(f(self.<a href="option.md#0x1_option_destroy_some">destroy_some</a>())) } <b>else</b> { self.<a href="option.md#0x1_option_destroy_none">destroy_none</a>(); <a href="option.md#0x1_option_none">none</a>() } } </code></pre> </details><a id="0x1_option_map_ref"></a>
map_refMaps the content of an option without destroying the original option.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_map_ref">map_ref</a><Element, OtherElement>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |&Element|OtherElement): <a href="option.md#0x1_option_Option">option::Option</a><OtherElement> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_map_ref">map_ref</a><Element, OtherElement>( self: &<a href="option.md#0x1_option_Option">Option</a><Element>, f: |&Element|OtherElement): <a href="option.md#0x1_option_Option">Option</a><OtherElement> { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>()) { <a href="option.md#0x1_option_some">some</a>(f(self.<a href="option.md#0x1_option_borrow">borrow</a>())) } <b>else</b> { <a href="option.md#0x1_option_none">none</a>() } } </code></pre> </details><a id="0x1_option_filter"></a>
filterFilters the content of an option
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_filter">filter</a><Element: drop>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, f: |&Element|bool): <a href="option.md#0x1_option_Option">option::Option</a><Element> </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_filter">filter</a><Element:drop>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, f: |&Element|bool): <a href="option.md#0x1_option_Option">Option</a><Element> { <b>if</b> (self.<a href="option.md#0x1_option_is_some">is_some</a>() && f(self.<a href="option.md#0x1_option_borrow">borrow</a>())) { self } <b>else</b> { <a href="option.md#0x1_option_none">none</a>() } } </code></pre> </details><a id="0x1_option_any"></a>
anyReturns true if the option contains an element which satisfies predicate.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_any">any</a><Element>(self: &<a href="option.md#0x1_option_Option">option::Option</a><Element>, p: |&Element|bool): bool </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_any">any</a><Element>(self: &<a href="option.md#0x1_option_Option">Option</a><Element>, p: |&Element|bool): bool { self.<a href="option.md#0x1_option_is_some">is_some</a>() && p(self.<a href="option.md#0x1_option_borrow">borrow</a>()) } </code></pre> </details><a id="0x1_option_destroy"></a>
destroyUtility function to destroy an option that is not droppable.
<pre><code><b>public</b> <b>fun</b> <a href="option.md#0x1_option_destroy">destroy</a><Element>(self: <a href="option.md#0x1_option_Option">option::Option</a><Element>, d: |Element|) </code></pre> <details> <summary>Implementation</summary> <pre><code><b>public</b> inline <b>fun</b> <a href="option.md#0x1_option_destroy">destroy</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, d: |Element|) { <b>let</b> vec = self.<a href="option.md#0x1_option_to_vec">to_vec</a>(); vec.<a href="option.md#0x1_option_destroy">destroy</a>(|e| d(e)); } </code></pre> </details><a id="@Specification_1"></a>
<a id="@Helper_Schema_2"></a>
<a id="0x1_option_AbortsIfNone"></a>
<pre><code><b>schema</b> <a href="option.md#0x1_option_AbortsIfNone">AbortsIfNone</a><Element> { self: <a href="option.md#0x1_option_Option">Option</a><Element>; <b>aborts_if</b> self.<a href="option.md#0x1_option_is_none">is_none</a>() <b>with</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>; } </code></pre><a id="@Specification_1_none"></a>
none<a id="0x1_option_spec_none"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_none">spec_none</a><Element>(): <a href="option.md#0x1_option_Option">Option</a><Element> { Option::None } </code></pre><a id="@Specification_1_some"></a>
some<a id="0x1_option_spec_some"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_some">spec_some</a><Element>(e: Element): <a href="option.md#0x1_option_Option">Option</a><Element> { Option::Some { e } } </code></pre><a id="@Specification_1_from_vec"></a>
from_vec<a id="@Specification_1_is_none"></a>
is_none<a id="0x1_option_spec_is_none"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_is_none">spec_is_none</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>): bool { self is Option::None<Element> } </code></pre><a id="@Specification_1_is_some"></a>
is_some<a id="0x1_option_spec_is_some"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_is_some">spec_is_some</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>): bool { self is Option::Some<Element> } </code></pre><a id="@Specification_1_contains"></a>
contains<a id="0x1_option_spec_contains"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_contains">spec_contains</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>, e: Element): bool { (self is Option::Some<Element>) && self.<a href="option.md#0x1_option_borrow">borrow</a>() == e } </code></pre><a id="@Specification_1_borrow"></a>
borrow<a id="0x1_option_spec_borrow"></a>
<pre><code><b>fun</b> <a href="option.md#0x1_option_spec_borrow">spec_borrow</a><Element>(self: <a href="option.md#0x1_option_Option">Option</a><Element>): Element { <b>if</b> (self is Option::Some<Element>) { self.e } <b>else</b> { <b>abort</b> <a href="option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a> } } </code></pre><a id="@Specification_1_borrow_with_default"></a>
borrow_with_default<a id="@Specification_1_get_with_default"></a>
get_with_default<a id="@Specification_1_fill"></a>
fill<a id="@Specification_1_extract"></a>
extract<a id="@Specification_1_borrow_mut"></a>
borrow_mut<a id="@Specification_1_swap"></a>
swap<a id="@Specification_1_swap_or_fill"></a>
swap_or_fill<a id="@Specification_1_destroy_with_default"></a>
destroy_with_default<a id="@Specification_1_destroy_some"></a>
destroy_some<a id="@Specification_1_destroy_none"></a>
destroy_none<a id="@Specification_1_to_vec"></a>
to_vec