Keyboard shortcuts

Press or to navigate between chapters

Press S or / to search in the book

Press ? to show this help

Press Esc to hide this help

String e &str

Sequência de caracteres UTF-8 que pode formar uma palavra ou frase, incluindo letras, números, símbolos ou qualquer outro tipo de caractere especial.

String

#![allow(unused)]
fn main() {
let frase: String = String::from("Um pouco de Rust para hoje!");
println!("{}", frase);
}

&str

#![allow(unused)]
fn main() {
let frase: &str = "Chega de Rust por hoje!";
println!("{}", frase);
}

O tópico String e &str será abordado melhor em um capítulo posterior.