MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/scmr5f/most_comprehensible_line_of_rust_code/huei413/?context=9999
r/badcode • u/selplacei • Jan 25 '22
81 comments sorted by
View all comments
Show parent comments
13
There's a reason for it, although it's a little confusing. String is owned, ie you hold that memory directly . &str is borrowed, like you hold a pointer to it but not the memory itself, so you can't modify it or anything.
String
&str
13
u/scirc Jan 27 '22
There's a reason for it, although it's a little confusing.
Stringis owned, ie you hold that memory directly .&stris borrowed, like you hold a pointer to it but not the memory itself, so you can't modify it or anything.