thomas-shirley.com

The byte values operator.

When you are dealing with string literials:

    let my_string = "hello world";

Sometimes we need to tell Rust that the string should be treated as a series of bytes. Why? Lots of built-in functions require string values as a series of bytes.

The way this is done, is by putting the letter 'b' before the string literal, like this:

    let my_string = b"hello world";

Bingo. The string will be interpreted as a series of bytes, rather than as a string literal.

Thomas - 01-09-2021