Created
September 17, 2025 14:07
-
-
Save mizchi/00858a6127b5c81c347dff513b00344d to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| ///| | |
| test "String to Bytes conversion" { | |
| fn find_index(url : Bytes) -> Int? { | |
| url.find("://") | |
| } | |
| let url = "https://www.example.ocom" | |
| let url_bytes : Bytes = "https://example.com" | |
| inspect(url.find("://"), content="Some(5)") | |
| inspect(find_index("https://example.com"), content="Some(5)") | |
| inspect(find_index(b"https://example.com"), content="Some(5)") | |
| inspect(find_index(url_bytes), content="Some(5)") | |
| inspect(find_index("https://example.com"), content="Some(5)") | |
| inspect(find_index(@encoding/utf8.encode(url)), content="Some(5)") | |
| // Can't compile | |
| // inspect(find_index(url), content="Some(5)") | |
| // Error: b'' and to_bytes() are different | |
| inspect(find_index(url.to_bytes()), content="Some(5)") | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment