DEV Community

loading...

Answer: What are the differences between Rust's `String` and `str`?

LisiurDay
・1 min read

They are actually completely different. First off, a str is nothing but a type level thing; it can only be reasoned about at the type level because it's a so-called dynamically-sized type (DST). The size the str takes up cannot be known at compile time and depends on runtime information…

Discussion (0)