Hacker News new | past | comments | ask | show | jobs | submit login

I’ve been using smartstrings, which is both excellent and maintained. https://github.com/bodil/smartstring



Ah, nice, I was looking at the smallstring package that's appears abandoned. I'll be sure to check this one out.

The good thing about having a decent type system is that I expect that transitioning to smartstrings should be painless! Thank you for that.


In case somebody stumbles upon this conversation in the future: I just migrated a project to use smartstrings and it works a bit differently from smallvec. Smallvec lets you decide how big you want to make the static buffer before it allocates, whereas smartstring's static buffer size is alsways `size_of::<String>() - 1`, that is 23 bytes on 64 bit architectures and 11 on 32 bits. If I want, say, a static 128B string smartstring won't do any better than std::string::String.

It's still a very nice lib though, and a smart optimization, but it doesn't cover all of my use cases for small string buffers.




Consider applying for YC's Spring batch! Applications are open till Feb 11.

Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: