Value of the *ptr in the String of capacity 0

⚓ Rust    📅 2025-09-02    👤 surdeus    👁️ 10      

surdeus

Warning

This post was published 92 days ago. The information described in this article may have changed.

Hello, I was wondering does preforming String::new() actually result in any heap allocation? I assume it wouldn't as that would imply we are allocating 0 bytes on the heap which at least to me is a little weird. But I was wondering that if it isn't the case what would be the value of the pointer in a String in that case, and how would we get that value?

4 posts - 3 participants

Read full topic

🏷️ Rust_feed