Skip to content

Commit

Permalink
[move] Add further support for enums in Move model (#18980)
Browse files Browse the repository at this point in the history
  • Loading branch information
tzakian authored Aug 14, 2024
1 parent c5766bc commit 9c4652f
Show file tree
Hide file tree
Showing 8 changed files with 310 additions and 49 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
#[allow(unused)]
module 0x42::m {
/// This is a doc comment above an enum
public enum Enum {
public enum Enum has drop {
/// This is a doc comment above a variant
A,
B(),
Expand All @@ -20,13 +20,28 @@ module 0x42::m {
B,
}

public struct X { x: Enum }
public struct X has drop { x: Enum }
public struct Y(Enum)

public struct XG { x: GenericEnum<Enum> }
public struct YG(GenericEnum<Enum>)

public struct XGG<T> { x: GenericEnum<T> }
public struct YGG<T>(GenericEnum<T>)

public struct VecMap<K: copy, V> has copy, drop, store {
contents: vector<Entry<K, V>>,
}

/// An entry in the map
public struct Entry<K: copy, V> has copy, drop, store {
key: K,
value: V,
}

/// Doc comments `type_: VecMap<u64, X>`
fun f(x: VecMap<u64, X>): u64 {
0
}
}

Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ This is a doc comment above an annotation.
- [Struct `YG`](#0x42_m_YG)
- [Struct `XGG`](#0x42_m_XGG)
- [Struct `YGG`](#0x42_m_YGG)
- [Struct `VecMap`](#0x42_m_VecMap)
- [Struct `Entry`](#0x42_m_Entry)
- [Enum `Enum`](#0x42_m_Enum)
- [Enum `GenericEnum`](#0x42_m_GenericEnum)
- [Function `f`](#0x42_m_f)


<pre><code></code></pre>
Expand All @@ -26,7 +29,7 @@ This is a doc comment above an annotation.



<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_X">X</a>
<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_X">X</a> <b>has</b> drop
</code></pre>


Expand Down Expand Up @@ -180,6 +183,67 @@ This is a doc comment above an annotation.
</dl>


</details>

<a name="0x42_m_VecMap"></a>

## Struct `VecMap`



<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;K: <b>copy</b>, V&gt; <b>has</b> <b>copy</b>, drop, store
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>contents: vector&lt;<a href="enums_test.md#0x42_m_Entry">m::Entry</a>&lt;K, V&gt;&gt;</code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x42_m_Entry"></a>

## Struct `Entry`

An entry in the map


<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_Entry">Entry</a>&lt;K: <b>copy</b>, V&gt; <b>has</b> <b>copy</b>, drop, store
</code></pre>



<details>
<summary>Fields</summary>


<dl>
<dt>
<code>key: K</code>
</dt>
<dd>

</dd>
<dt>
<code>value: V</code>
</dt>
<dd>

</dd>
</dl>


</details>

<a name="0x42_m_Enum"></a>
Expand All @@ -189,7 +253,7 @@ This is a doc comment above an annotation.
This is a doc comment above an enum


<pre><code><b>public</b> enum Enum
<pre><code><b>public</b> enum Enum <b>has</b> drop
</code></pre>


Expand Down Expand Up @@ -315,4 +379,29 @@ Variant <code>B</code>
</dl>


</details>

<a name="0x42_m_f"></a>

## Function `f`

Doc comments <code>type_: <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">X</a>&gt;</code>


<pre><code><b>fun</b> <a href="enums_test.md#0x42_m_f">f</a>(x: <a href="enums_test.md#0x42_m_VecMap">m::VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">m::X</a>&gt;): u64
</code></pre>



<details>
<summary>Implementation</summary>


<pre><code><b>fun</b> <a href="enums_test.md#0x42_m_f">f</a>(x: <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">X</a>&gt;): u64 {
0
}
</code></pre>



</details>
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,11 @@ This is a doc comment above an annotation.
- [Struct `YG`](#0x42_m_YG)
- [Struct `XGG`](#0x42_m_XGG)
- [Struct `YGG`](#0x42_m_YGG)
- [Struct `VecMap`](#0x42_m_VecMap)
- [Struct `Entry`](#0x42_m_Entry)
- [Enum `Enum`](#0x42_m_Enum)
- [Enum `GenericEnum`](#0x42_m_GenericEnum)
- [Function `f`](#0x42_m_f)


<pre><code></code></pre>
Expand All @@ -26,7 +29,7 @@ This is a doc comment above an annotation.



<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_X">X</a>
<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_X">X</a> <b>has</b> drop
</code></pre>


Expand Down Expand Up @@ -164,14 +167,69 @@ This is a doc comment above an annotation.
</dl>


<a name="0x42_m_VecMap"></a>

## Struct `VecMap`



<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;K: <b>copy</b>, V&gt; <b>has</b> <b>copy</b>, drop, store
</code></pre>



##### Fields


<dl>
<dt>
<code>contents: vector&lt;<a href="enums_test.md#0x42_m_Entry">m::Entry</a>&lt;K, V&gt;&gt;</code>
</dt>
<dd>

</dd>
</dl>


<a name="0x42_m_Entry"></a>

## Struct `Entry`

An entry in the map


<pre><code><b>struct</b> <a href="enums_test.md#0x42_m_Entry">Entry</a>&lt;K: <b>copy</b>, V&gt; <b>has</b> <b>copy</b>, drop, store
</code></pre>



##### Fields


<dl>
<dt>
<code>key: K</code>
</dt>
<dd>

</dd>
<dt>
<code>value: V</code>
</dt>
<dd>

</dd>
</dl>


<a name="0x42_m_Enum"></a>

## Enum `Enum`

This is a doc comment above an enum


<pre><code><b>public</b> enum Enum
<pre><code><b>public</b> enum Enum <b>has</b> drop
</code></pre>


Expand Down Expand Up @@ -291,3 +349,24 @@ Variant <code>B</code>

</dd>
</dl>


<a name="0x42_m_f"></a>

## Function `f`

Doc comments <code>type_: <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">X</a>&gt;</code>


<pre><code><b>fun</b> <a href="enums_test.md#0x42_m_f">f</a>(x: <a href="enums_test.md#0x42_m_VecMap">m::VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">m::X</a>&gt;): u64
</code></pre>



##### Implementation


<pre><code><b>fun</b> <a href="enums_test.md#0x42_m_f">f</a>(x: <a href="enums_test.md#0x42_m_VecMap">VecMap</a>&lt;u64, <a href="enums_test.md#0x42_m_X">X</a>&gt;): u64 {
0
}
</code></pre>
Loading

0 comments on commit 9c4652f

Please sign in to comment.