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

Unexpected behaviour of the str::from builtin function #169

Closed
VianneyRousset opened this issue Oct 10, 2024 · 4 comments
Closed

Unexpected behaviour of the str::from builtin function #169

VianneyRousset opened this issue Oct 10, 2024 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@VianneyRousset
Copy link

VianneyRousset commented Oct 10, 2024

The str::from builtin function is useful to convert value to a string, however the latter has an unexpected output when a string is given as argument.

"foo " + str::from(42) returns foo 42 which is fine.
"foo " + str::from("bar") returns foo "bar", when it should be foo bar.

@VianneyRousset
Copy link
Author

The str::from builtin function uses the Value::to_string implemented for the Display trait:

            Value::String(string) => write!(f, "\"{}\"", string),

The extra quotation marks above are the issue and does not follow the standard fmt() of a string. I guess that was a deliberate choice?

@ISibboI
Copy link
Owner

ISibboI commented Oct 11, 2024 via email

@VianneyRousset
Copy link
Author

Done in #170.

Please note the choice has been made that applying str:from to a tuple will still add those quotation marks to contained strings.

Therefore, str::from((42, true, "foo")) returns (42, true, "foo").

@ISibboI ISibboI self-assigned this Oct 11, 2024
@ISibboI ISibboI added the bug Something isn't working label Oct 11, 2024
@ISibboI
Copy link
Owner

ISibboI commented Oct 12, 2024

Thanks for fixing this! I'll hopefully be able to make a release during the next week.

@ISibboI ISibboI closed this as completed Oct 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants