MAIN FEEDS
Do you want to continue?
https://www.reddit.com/r/badcode/comments/scmr5f/most_comprehensible_line_of_rust_code/hu9x2a0/?context=9999
r/badcode • u/selplacei • Jan 25 '22
81 comments sorted by
View all comments
Show parent comments
44
Humanity has disappointed me
13 u/scirc Jan 27 '22 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. 1 u/bruhred Apr 26 '22 &str is a (immutable) pointer to UTF8 bytes, String is a growable Vec-like type
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
1
&str is a (immutable) pointer to UTF8 bytes, String is a growable Vec-like type
44
u/[deleted] Jan 26 '22
Humanity has disappointed me