std-module

std::str — borrowed text utilities

Use this module for UTF-8 validation, string iterators and parsing interfaces. The primitive str has its own inherent methods. Expected stdout (not executed): Rust Common mistake: Confusing the module path with the primitive type.

Formal Syntax & Structure

rust syntaxrust
std::str::from_utf8(bytes)

Working Example

Example Snippetrust
fn main() {    let data = [82, 117, 115, 116];    let text = std::str::from_utf8(&data).unwrap();    println!("{text}");}
Rust Reference