-
Notifications
You must be signed in to change notification settings - Fork 119
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
Bump::alloc_str #50
Bump::alloc_str #50
Conversation
This is similar to allocating slices, but for string slices. Because string slices are a strange beast and none of the other methods can be used *directly*. It could be done at the caller side, but then the user would need to use `unsafe` which might be unacceptable in business-logic applications or crates (or be content with the needless check for utf8 which is already guaranteed to be valid).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Awesome! Would you like to add a alloc_str_with
function in a follow up PR as well?
I'm not against it and I'd add it, but I'm not sure about its semantics/signature. I mean, all these slice But it's possible I'm missing something obvious so if you just tell me how it should look like, I'll be happy to implement it. |
Ah, that isn't quite what I was thinking, but upon reflection what I was thinking might not make sense either. This was what I was originally thinking: fn alloc_str_with<'a>(&self, f: impl FnOnce() -> &'a str) -> &mut str {
...
} This doesn't make sense for a couple reasons:
We could solve (2) by accepting any Ultimately, I think building strings in the bump arena (as opposed to copying them in) is better served by Anyways, thanks again for this PR! |
If there's no follow-up PR for this feature, would it be OK to have a release? |
I'll file a new issue discussing a new release, since it is going to be a breaking release, I want to double check all the ducks are in the right rows. |
This is similar to allocating slices, but for string slices. Because
string slices are a strange beast and none of the other methods can be
used directly. It could be done at the caller side, but then the user
would need to use
unsafe
which might be unacceptable in business-logicapplications or crates (or be content with the needless check for utf8
which is already guaranteed to be valid).