-
What is the difference between String and &str in Rust? |
Beta Was this translation helpful? Give feedback.
Answered by
Tvenus
Jul 15, 2024
Replies: 1 comment
-
String is a heap-allocated, growable string type, while &str is a slice (reference) to a string. String can be modified and owns its data, whereas &str is immutable and does not own the data it points to. |
Beta Was this translation helpful? Give feedback.
0 replies
Answer selected by
Omokami
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
String is a heap-allocated, growable string type, while &str is a slice (reference) to a string. String can be modified and owns its data, whereas &str is immutable and does not own the data it points to.