DEV Community

Pascal Precht
Pascal Precht

Posted on

Understanding String and &str in Rust

Most likely, soon after you’ve started your Rust journey, you ran into this scenario where you tried to work with string types (or should I say, you thought you were?), and the compiler refused to compile your code because of something that looks like a string, actually isn’t a string.

I've been there as well. That's why I wrote an article that explains the difference between String and &str in Rust:

https://blog.thoughtram.io/string-vs-str-in-rust/

Let me know what you think in the comments below and what you want to learn about next!

Top comments (0)