Skip to content

Glossary: Coding Interviews in Rust

as_bytes()

Also written: as_bytes, bytes, b'.'

A `str` method that returns the string's bytes as a slice, so you can read one character by position, which a `str` doesn't allow directly. It suits plain ASCII text, such as grid cells or palindrome checks, where you compare against byte literals like `b'#'`.

Where the book teaches it

Related terms

GridPalindrome