Over the weekend, I was working on a personal Rust project when I ran into an excessive memory usage problem. After an evening of trial and error, I found a workaround to fix the memory usage, but I still didn’t understand how the issue was even possible, so I then spent another evening digging through the source code of the Rust standard library to understand the root cause.
For shared, immutable lists, you can also use
Arc/Rcin place ofBox! I guess what’s surprising is that[T](andstr/Path/OsStr/etc) are traditionally associated with shared borrows (like&[T]), but they’re really just unsized types that can be used anywhere there’s a?Sizedbound.Also, overuse of lists (as opposed to other data structures) seems to be a common problem in all programming languages among less experienced devs since they’re simple enough to use in most places. Not saying that’s what happened to the author though - these types are way less obvious than something like a hash set or queue.