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

Idea: ToBumpString #74

Open
richard-uk1 opened this issue May 2, 2020 · 1 comment
Open

Idea: ToBumpString #74

richard-uk1 opened this issue May 2, 2020 · 1 comment

Comments

@richard-uk1
Copy link
Contributor

I find I end up writing

let x = bumpalo::format!(in cx.bump, "{}", var).into_bump_str();

a lot, so my suggestion is to add

trait ToBumpString: Display {
    fn to_bump_str<'a>(&self, arena: &'a Bump) -> &'a str {
        bumpalo::format!(in arena, "{}", var).into_bump_str();
    }

matching ToString (except that we want a &str).

@fitzgen fitzgen transferred this issue from fitzgen/dodrio May 8, 2020
@fitzgen
Copy link
Owner

fitzgen commented May 8, 2020

This makes sense to me, but in the bumpalo crate.

ToString doesn't require Display, but instead has a blanket implementation for all T: Display. I think it makes sense to copy that here.

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

No branches or pull requests

2 participants