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

Avoid string conversion when working with Value #70

Open
tgross35 opened this issue Jul 21, 2023 · 1 comment
Open

Avoid string conversion when working with Value #70

tgross35 opened this issue Jul 21, 2023 · 1 comment

Comments

@tgross35
Copy link

Rather than having Value always be a String, something like this could be better:

enum Value {
    String(String),
    Integer(i64),
    Float(f64),
}

And then the From implementations would just set an Integer or Float. This would be nice because it means that numbers (which account for a lot of possible values) never have to allocate.

Doing deref to str wouldn't be the best thing with this change. Something like as_string() -> String might be better suited.

@IvanUkhov
Copy link
Member

Thank you! I don't remember all the details off the top of my head, but that seems very much reasonable. If you want and have time, you could give it a try. I would be happy to review the PR.

@IvanUkhov IvanUkhov changed the title Change Value to an enum Avoid string conversion when working with Value Jul 22, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Development

No branches or pull requests

2 participants