it store the capacity?
Under C the length of an string is defined by an null character. This causes problems if the byte is missing or shows up in the middle of the string. Rust stores the length to prevent these type of problems.
i think length is not capacity, length is how long the data is, while capacity is how much it can grow before needing to be reallocated
Because it's just a struct, it's not that smart
what about the "dont pay for what you're not using" concept? why would i "pay" for memory usage thats not gonna be used?
Your responsibility to not pick a mutable String type then
i already dont. the thing is that i saw in more than one place people saying that "Arc<str> is more efficient than String because uses 8 less bytes" because String stores the capacity, the entire argument is about immutable variables
Обсуждают сегодня