Skip to content
This repository has been archived by the owner on May 4, 2024. It is now read-only.

[move-stdlib] formatting the string module codes #1070

Merged
merged 2 commits into from
Aug 19, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions language/move-stdlib/docs/string.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ Creates a new string from a sequence of bytes. Aborts if the bytes do not repres

<pre><code><b>public</b> <b>fun</b> <a href="string.md#0x1_string_utf8">utf8</a>(bytes: <a href="vector.md#0x1_vector">vector</a>&lt;u8&gt;): <a href="string.md#0x1_string_String">String</a> {
<b>assert</b>!(<a href="string.md#0x1_string_internal_check_utf8">internal_check_utf8</a>(&bytes), <a href="string.md#0x1_string_EINVALID_UTF8">EINVALID_UTF8</a>);
<a href="string.md#0x1_string_String">String</a>{bytes}
<a href="string.md#0x1_string_String">String</a> { bytes }
}
</code></pre>

Expand All @@ -127,7 +127,7 @@ Tries to create a new string from a sequence of bytes.

<pre><code><b>public</b> <b>fun</b> <a href="string.md#0x1_string_try_utf8">try_utf8</a>(bytes: <a href="vector.md#0x1_vector">vector</a>&lt;u8&gt;): Option&lt;<a href="string.md#0x1_string_String">String</a>&gt; {
<b>if</b> (<a href="string.md#0x1_string_internal_check_utf8">internal_check_utf8</a>(&bytes)) {
<a href="option.md#0x1_option_some">option::some</a>(<a href="string.md#0x1_string_String">String</a>{bytes})
<a href="option.md#0x1_option_some">option::some</a>(<a href="string.md#0x1_string_String">String</a> { bytes })
} <b>else</b> {
<a href="option.md#0x1_option_none">option::none</a>()
}
Expand Down Expand Up @@ -321,7 +321,7 @@ guaranteeing that the result is valid utf8.
j &lt;= l && i &lt;= j && <a href="string.md#0x1_string_internal_is_char_boundary">internal_is_char_boundary</a>(bytes, i) && <a href="string.md#0x1_string_internal_is_char_boundary">internal_is_char_boundary</a>(bytes, j),
<a href="string.md#0x1_string_EINVALID_INDEX">EINVALID_INDEX</a>
);
<a href="string.md#0x1_string_String">String</a>{bytes: <a href="string.md#0x1_string_internal_sub_string">internal_sub_string</a>(bytes, i, j)}
<a href="string.md#0x1_string_String">String</a> { bytes: <a href="string.md#0x1_string_internal_sub_string">internal_sub_string</a>(bytes, i, j) }
}
</code></pre>

Expand Down
6 changes: 3 additions & 3 deletions language/move-stdlib/sources/string.move
Original file line number Diff line number Diff line change
Expand Up @@ -17,13 +17,13 @@ module std::string {
/// Creates a new string from a sequence of bytes. Aborts if the bytes do not represent valid utf8.
public fun utf8(bytes: vector<u8>): String {
assert!(internal_check_utf8(&bytes), EINVALID_UTF8);
String{bytes}
String { bytes }
}

/// Tries to create a new string from a sequence of bytes.
public fun try_utf8(bytes: vector<u8>): Option<String> {
if (internal_check_utf8(&bytes)) {
option::some(String{bytes})
option::some(String { bytes })
} else {
option::none()
}
Expand Down Expand Up @@ -77,7 +77,7 @@ module std::string {
j <= l && i <= j && internal_is_char_boundary(bytes, i) && internal_is_char_boundary(bytes, j),
EINVALID_INDEX
);
String{bytes: internal_sub_string(bytes, i, j)}
String { bytes: internal_sub_string(bytes, i, j) }
}

/// Computes the index of the first occurrence of a string. Returns `length(s)` if no occurrence found.
Expand Down
Loading