When should I use String vs &str?

from blog Steve Klabnik, | ↗ original
Oct 06 2024Oct 06 2024 Rust has two main string types: Rust has two main string types: StringString and and &str&str. Sometimes, people argue that these two types make Rust code difficult to write, because you have to think about which one you should be using in a given situation. My experience of writing Rust is that I don’t really think about this very much, and this post is about some rules of thumb that you can use to be like me.. Sometimes, people argue that these two types make Rust code difficult to write, because you have to think about which one you should be using in a given situation. My experience of writing Rust is that I don’t really think about this very much, and this post is about some rules of thumb that you can use to be like me. Level 1: Don’t...Level 1: Don’t...