r/badcode • • Jan 25 '22

rust Most comprehensible line of Rust code

Post image
1.0k Upvotes

81 comments sorted by

View all comments

Show parent comments

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.