Skip to content

Commit

Permalink
Add disclaimer on bytearray.to_string
Browse files Browse the repository at this point in the history
  • Loading branch information
KtorZ committed Mar 14, 2024
1 parent 2725b16 commit fc3b9d5
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions lib/aiken/bytearray.ak
Original file line number Diff line number Diff line change
Expand Up @@ -387,8 +387,14 @@ test take_4() {

/// Convert a `ByteArray` into a `String`.
///
/// <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](#to_hex).
/// --- | ---
///
///
/// ```aiken
/// bytearray.to_string(#"414243") == "ABC"
///
/// bytearray.to_string(some_hash) -> fail
/// ```
pub fn to_string(self: ByteArray) -> String {
builtin.decode_utf8(self)
Expand Down

0 comments on commit fc3b9d5

Please sign in to comment.