Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add EcoString::truncate #45

Open
ronnodas opened this issue Feb 16, 2025 · 1 comment · May be fixed by #46
Open

Add EcoString::truncate #45

ronnodas opened this issue Feb 16, 2025 · 1 comment · May be fixed by #46

Comments

@ronnodas
Copy link

Should behave like String::truncate, ie panic if new_len not on a char boundary. The "same" implementation should work too, although I was expecting DynamicVec::truncate to move from Spilled to Inline if new_len <= 15 but it doesn't seem to do that. I can try making a PR for one or both of these things if they sound like improvements.

@laurmaedje
Copy link
Member

I was expecting DynamicVec::truncate to move from Spilled to Inline if new_len <= 15 but it doesn't seem to do that.

It doesn't do that because you might go above and below the limit frequently and then it would have a ton of allocations. Works the same way in smallvec.

I'm open for a PR that adds a EcoString::truncate behaving just like std's.

@ronnodas ronnodas linked a pull request Feb 19, 2025 that will close this issue
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants