Skip to content

Commit b57389f

Browse files
committed
Also add disclaimer on string.from_bytearray
1 parent fc3b9d5 commit b57389f

File tree

1 file changed

+6
-0
lines changed

1 file changed

+6
-0
lines changed

lib/aiken/string.ak

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,15 @@ test concat_3() {
2626

2727
/// Convert a `ByteArray` into a `String`
2828
///
29+
/// <br/>⚠️<pre>WARNING</pre> | This functions fails if the underlying `ByteArray` isn't UTF-8-encoded. <br/>In particular, you cannot convert arbitrary hash digests using this function. <br/>For converting arbitrary `ByteArray`s, use [bytearray.to_hex](../bytearray.html#to_hex).
30+
/// --- | ---
31+
///
2932
/// ```aiken
3033
/// string.from_bytearray("foo") == @"foo"
34+
///
3135
/// string.from_bytearray(#"666f6f") == @"foo"
36+
///
37+
/// string.from_bytearray(some_hash) -> fail
3238
/// ```
3339
pub fn from_bytearray(bytes: ByteArray) -> String {
3440
decode_utf8(bytes)

0 commit comments

Comments
 (0)