Skip to content
This repository has been archived by the owner on Oct 17, 2023. It is now read-only.

chore: str as_bytes() doc #343

Merged
merged 1 commit into from
Aug 21, 2023
Merged
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
14 changes: 14 additions & 0 deletions docs/language_concepts/00_data_types.md
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,20 @@ fn main(message : pub str<11>, hex_as_string : str<4>) {
}
```

You can convert a `str<N>` to a byte array by calling `as_bytes()`
or a vector by calling `as_bytes_vec()`.

```rust
fn main() {
let message = "hello world";
let message_bytes = message.as_bytes();
let mut message_vec = message.as_bytes_vec();
assert(message_bytes.len() == 11);
assert(message_bytes[0] == 104);
assert(message_bytes[0] == message_vec.get(0));
}
```

## Compound Types

A compound type groups together multiple values into one type. Elements within a compound type can
Expand Down