fitzgen / bumpalo

A fast bump allocation arena for Rust
https://docs.rs/bumpalo
Apache License 2.0
1.35k stars 110 forks source link

Add `Bump::alloc_str_concat` #203

Closed SabrinaJewson closed 1 year ago

SabrinaJewson commented 1 year ago

I thought this would be a useful function to have. The motivation behind the &impl AsRef<str> design is that it greatly simplifies the implementation in comparison to impl AsRef<str> (see the previous commit) — also, as the iterator is iterated twice users should be producing references anyway.

SabrinaJewson commented 1 year ago

That’s true — I was motivated to make this PR by the fact that it does require some unsafe code that is non-trivial to get right. The thing to me is that the majority of cases where people would benefit from this method they’ll end up using .alloc_str(&format! instead which is much slower — on the other hand, if this method is supported they’ll just have faster code. So to me it feels more like an optimization in this library, rather than just additional API surface.

fitzgen commented 1 year ago

Thanks for opening this PR, but after some consideration I don't think it belongs here.