wezm / read-rust

Read Rust allows you to keep up with articles about the Rust programming language.
https://readrust.net/
MIT License
198 stars 11 forks source link

Add post #154

Closed sgrowe closed 4 years ago

sgrowe commented 4 years ago

Hi, just wanted to suggest a couple of posts from my blog:

Post URL: https://fullstackmilk.dev/string_vs_&str_in_rust/ Author Name: Sam Rowe Categories: Getting Started

Post URL: https://fullstackmilk.dev/efficiently_escaping_strings_using_cow_in_rust/ Author Name: Sam Rowe Categories: Performance

Blog RSS/Atom/JSON Feed: https://fullstackmilk.dev/feed.xml

wezm commented 4 years ago

Thanks Sam. I'm a bit behind in my Read Rust publishing. I'll try to get those posted soon. I'm actually already subscribed to your feed and see that I have those two posts waiting to be read. :)

wezm commented 4 years ago

A comment on the first post:

&str points to data that's already stored in a String

This is not necessarily the case. A string slice is not necessarily backed by a heap allocated String. The most common example of this is string literals. These are stored in the .rodata segment of the binary, thus they are a reference to that read-only (non-heap allocated) data.

Another example is the string slice could be a view into a C string (created via CStr::to_str).

Not sure if that distinction is important to you or not, but I thought I'd mention it.

sgrowe commented 4 years ago

Oh cool. Yeah, no rush with posting things.

And thanks for the feedback on the first post! I agree it was potentially a bit misleading so I've updated that a bit now :-)

wezm commented 4 years ago

Cool, both posts have been published now.