|
| 1 | + |
| 2 | +<a name="0x1_type_name"></a> |
| 3 | + |
| 4 | +# Module `0x1::type_name` |
| 5 | + |
| 6 | +Functionality for converting Move types into values. Use with care! |
| 7 | + |
| 8 | + |
| 9 | +- [Struct `TypeName`](#0x1_type_name_TypeName) |
| 10 | +- [Function `get`](#0x1_type_name_get) |
| 11 | +- [Function `borrow_string`](#0x1_type_name_borrow_string) |
| 12 | +- [Function `into_string`](#0x1_type_name_into_string) |
| 13 | + |
| 14 | + |
| 15 | +<pre><code><b>use</b> <a href="ascii.md#0x1_ascii">0x1::ascii</a>; |
| 16 | +</code></pre> |
| 17 | + |
| 18 | + |
| 19 | + |
| 20 | +<a name="0x1_type_name_TypeName"></a> |
| 21 | + |
| 22 | +## Struct `TypeName` |
| 23 | + |
| 24 | + |
| 25 | + |
| 26 | +<pre><code><b>struct</b> <a href="type_name.md#0x1_type_name_TypeName">TypeName</a> <b>has</b> <b>copy</b>, drop, store |
| 27 | +</code></pre> |
| 28 | + |
| 29 | + |
| 30 | + |
| 31 | +<details> |
| 32 | +<summary>Fields</summary> |
| 33 | + |
| 34 | + |
| 35 | +<dl> |
| 36 | +<dt> |
| 37 | +<code>name: <a href="ascii.md#0x1_ascii_String">ascii::String</a></code> |
| 38 | +</dt> |
| 39 | +<dd> |
| 40 | + String representation of the type. All types are represented |
| 41 | + using their source syntax: |
| 42 | + "u8", "u64", "u128", "bool", "address", "vector", "signer" for ground types. |
| 43 | + Struct types are represented as fully qualified, <code>0x</code>-prefixed short type names |
| 44 | + <code><a href="string.md#0x1_string_String">0x1::string::String</a></code> or |
| 45 | + <code>0xabcd::module_name1::type_name1<0x1234::module_name2::type_name2<u64>></code> |
| 46 | + Note: addresses in short type names are *always* shortened by stripping leading 0's |
| 47 | + e.g., 0xA rather than 0x00000000A, |
| 48 | +</dd> |
| 49 | +</dl> |
| 50 | + |
| 51 | + |
| 52 | +</details> |
| 53 | + |
| 54 | +<a name="0x1_type_name_get"></a> |
| 55 | + |
| 56 | +## Function `get` |
| 57 | + |
| 58 | +Return a value representation of the type <code>T</code>. |
| 59 | + |
| 60 | + |
| 61 | +<pre><code><b>public</b> <b>fun</b> <a href="type_name.md#0x1_type_name_get">get</a><T>(): <a href="type_name.md#0x1_type_name_TypeName">type_name::TypeName</a> |
| 62 | +</code></pre> |
| 63 | + |
| 64 | + |
| 65 | + |
| 66 | +<details> |
| 67 | +<summary>Implementation</summary> |
| 68 | + |
| 69 | + |
| 70 | +<pre><code><b>public</b> <b>native</b> <b>fun</b> <a href="type_name.md#0x1_type_name_get">get</a><T>(): <a href="type_name.md#0x1_type_name_TypeName">TypeName</a>; |
| 71 | +</code></pre> |
| 72 | + |
| 73 | + |
| 74 | + |
| 75 | +</details> |
| 76 | + |
| 77 | +<a name="0x1_type_name_borrow_string"></a> |
| 78 | + |
| 79 | +## Function `borrow_string` |
| 80 | + |
| 81 | +Get the String representation of <code>self</code> |
| 82 | + |
| 83 | + |
| 84 | +<pre><code><b>public</b> <b>fun</b> <a href="type_name.md#0x1_type_name_borrow_string">borrow_string</a>(self: &<a href="type_name.md#0x1_type_name_TypeName">type_name::TypeName</a>): &<a href="ascii.md#0x1_ascii_String">ascii::String</a> |
| 85 | +</code></pre> |
| 86 | + |
| 87 | + |
| 88 | + |
| 89 | +<details> |
| 90 | +<summary>Implementation</summary> |
| 91 | + |
| 92 | + |
| 93 | +<pre><code><b>public</b> <b>fun</b> <a href="type_name.md#0x1_type_name_borrow_string">borrow_string</a>(self: &<a href="type_name.md#0x1_type_name_TypeName">TypeName</a>): &String { |
| 94 | + &self.name |
| 95 | +} |
| 96 | +</code></pre> |
| 97 | + |
| 98 | + |
| 99 | + |
| 100 | +</details> |
| 101 | + |
| 102 | +<a name="0x1_type_name_into_string"></a> |
| 103 | + |
| 104 | +## Function `into_string` |
| 105 | + |
| 106 | +Convert <code>self</code> into its inner String |
| 107 | + |
| 108 | + |
| 109 | +<pre><code><b>public</b> <b>fun</b> <a href="type_name.md#0x1_type_name_into_string">into_string</a>(self: <a href="type_name.md#0x1_type_name_TypeName">type_name::TypeName</a>): <a href="ascii.md#0x1_ascii_String">ascii::String</a> |
| 110 | +</code></pre> |
| 111 | + |
| 112 | + |
| 113 | + |
| 114 | +<details> |
| 115 | +<summary>Implementation</summary> |
| 116 | + |
| 117 | + |
| 118 | +<pre><code><b>public</b> <b>fun</b> <a href="type_name.md#0x1_type_name_into_string">into_string</a>(self: <a href="type_name.md#0x1_type_name_TypeName">TypeName</a>): String { |
| 119 | + self.name |
| 120 | +} |
| 121 | +</code></pre> |
| 122 | + |
| 123 | + |
| 124 | + |
| 125 | +</details> |
| 126 | + |
| 127 | + |
| 128 | +[//]: # ("File containing references which can be used from documentation") |
0 commit comments