Skip to content

Commit

Permalink
Revert "Revert "[std] Better ASCII methods + minor cleanup in std (#1…
Browse files Browse the repository at this point in the history
…7380)""

This reverts commit 85b4432.
  • Loading branch information
dariorussi committed May 14, 2024
1 parent 413d8af commit c35fc2d
Show file tree
Hide file tree
Showing 23 changed files with 818 additions and 211 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,10 +3,7 @@

/// Example coin with a trusted owner responsible for minting/burning (e.g., a stablecoin)
module examples::trusted_coin {
use std::option;
use sui::coin::{Self, TreasuryCap};
use sui::transfer;
use sui::tx_context::{Self, TxContext};

/// Name of the coin
public struct TRUSTED_COIN has drop {}
Expand Down
303 changes: 296 additions & 7 deletions crates/sui-framework/docs/move-stdlib/ascii.md

Large diffs are not rendered by default.

22 changes: 11 additions & 11 deletions crates/sui-framework/docs/move-stdlib/option.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,24 +65,24 @@ zero or one because Move bytecode does not have ADTs.
## Constants


<a name="0x1_option_EOPTION_IS_SET"></a>
<a name="0x1_option_EOptionIsSet"></a>

The <code><a href="../move-stdlib/option.md#0x1_option_Option">Option</a></code> is in an invalid state for the operation attempted.
The <code><a href="../move-stdlib/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="../move-stdlib/option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a>: u64 = 262144;
<pre><code><b>const</b> <a href="../move-stdlib/option.md#0x1_option_EOptionIsSet">EOptionIsSet</a>: u64 = 262144;
</code></pre>



<a name="0x1_option_EOPTION_NOT_SET"></a>
<a name="0x1_option_EOptionNotSet"></a>

The <code><a href="../move-stdlib/option.md#0x1_option_Option">Option</a></code> is in an invalid state for the operation attempted.
The <code><a href="../move-stdlib/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="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>: u64 = 262145;
<pre><code><b>const</b> <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>: u64 = 262145;
</code></pre>


Expand Down Expand Up @@ -231,7 +231,7 @@ Aborts if <code>t</code> does not hold a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_borrow">borrow</a>&lt;Element&gt;(t: &<a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;): &Element {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>);
&t.vec[0]
}
</code></pre>
Expand Down Expand Up @@ -319,7 +319,7 @@ Aborts if <code>t</code> already holds a value
<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_fill">fill</a>&lt;Element&gt;(t: &<b>mut</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;, e: Element) {
<b>let</b> vec_ref = &<b>mut</b> t.vec;
<b>if</b> (vec_ref.is_empty()) vec_ref.push_back(e)
<b>else</b> <b>abort</b> <a href="../move-stdlib/option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a>
<b>else</b> <b>abort</b> <a href="../move-stdlib/option.md#0x1_option_EOptionIsSet">EOptionIsSet</a>
}
</code></pre>

Expand All @@ -345,7 +345,7 @@ Aborts if <code>t</code> does not hold a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_extract">extract</a>&lt;Element&gt;(t: &<b>mut</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;): Element {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>);
t.vec.pop_back()
}
</code></pre>
Expand All @@ -372,7 +372,7 @@ Aborts if <code>t</code> does not hold a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_borrow_mut">borrow_mut</a>&lt;Element&gt;(t: &<b>mut</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;): &<b>mut</b> Element {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>);
&<b>mut</b> t.vec[0]
}
</code></pre>
Expand All @@ -399,7 +399,7 @@ Aborts if <code>t</code> does not hold a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_swap">swap</a>&lt;Element&gt;(t: &<b>mut</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;, e: Element): Element {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>);
<b>let</b> vec_ref = &<b>mut</b> t.vec;
<b>let</b> old_value = vec_ref.pop_back();
vec_ref.push_back(e);
Expand Down Expand Up @@ -487,7 +487,7 @@ Aborts if <code>t</code> does not hold a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_destroy_some">destroy_some</a>&lt;Element&gt;(t: <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;): Element {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_NOT_SET">EOPTION_NOT_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_some">is_some</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionNotSet">EOptionNotSet</a>);
<b>let</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a> { <b>mut</b> vec } = t;
<b>let</b> elem = vec.pop_back();
vec.destroy_empty();
Expand Down Expand Up @@ -517,7 +517,7 @@ Aborts if <code>t</code> holds a value


<pre><code><b>public</b> <b>fun</b> <a href="../move-stdlib/option.md#0x1_option_destroy_none">destroy_none</a>&lt;Element&gt;(t: <a href="../move-stdlib/option.md#0x1_option_Option">Option</a>&lt;Element&gt;) {
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_none">is_none</a>(), <a href="../move-stdlib/option.md#0x1_option_EOPTION_IS_SET">EOPTION_IS_SET</a>);
<b>assert</b>!(t.<a href="../move-stdlib/option.md#0x1_option_is_none">is_none</a>(), <a href="../move-stdlib/option.md#0x1_option_EOptionIsSet">EOptionIsSet</a>);
<b>let</b> <a href="../move-stdlib/option.md#0x1_option_Option">Option</a> { vec } = t;
vec.destroy_empty()
}
Expand Down
Loading

0 comments on commit c35fc2d

Please sign in to comment.