Need Assistance?

support@tutorialshub.in

Collections in Rust

String vs &str & UTF-8 Text

ADVERTISEMENT
Rust Free Lesson
5 min read
ADVERTISEMENT

Rust strings are always valid UTF-8. Because a single emoji or accented character can take 2–4 bytes, Rust doesn't allow indexing a string like s[0]—instead, iterate cleanly with s.chars().

ADVERTISEMENT
Hi, I'm Tuby! Here to help you