-
Notifications
You must be signed in to change notification settings - Fork 86
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
Blanket implementation for T: ToString
?
#91
Comments
Hi @aldanor, I assume you meant Without specialisation, implementing I can see the use case of have an implementation for types implementing If the use case is specific to Rust primitives, we could extend implementations of |
https://github.com/SergioBenitez/yansi#why:
Probably its source can help this issue. For now println!("{}", 42.to_string().green()); is the way to go with |
I just found myself wanting to be able to apply colors to |
Maybe as a workaround until specialized traits hit stable, a specific implementation for all primitives could be added to make this work for example: println!("{}", 42.red()); Thoughts? |
I'm sorry to mention another crate but I do it with the best intentions 😃
Just found it, exactly what I was looking for, so maybe it's what you need too? |
Thank you @murlakatamenka for prividing links to owo-colors and yansi, that's very interesting. There's no reason we can't have the best of all these worlds. |
Hey! I've recently joined the team for the project, and I'd like to start looking at getting this tackled. I've thought about what might be best way to
From what I've read formatters don't necessarily do any allocations in themselves, but I'd have to look into what specific scenarios they end up doing so. Is there any places you'd know of where they for sure allocate? If there's any way you were wanting to get this done as well @mackwic I'm definitely all ears for it. Really glad to just get this project going on it's feet! |
Considering my current available time, I'm not able to help on this, sorry. |
That sounds good @mackwic, I'll probably end up doing an |
What I'm thinking of doing is just having #139 be how anything can be formatted. It would be a breaking API change due to how items would have to be stored internally, but there's some other changes that I think could be good for the project (like implementing |
I think go with #139 and that will add this kind of functionality. |
Why not implement this?
Note that this will also automatically cover all types that implement
Display
due toToString
's blanket implementation.This way, you can, e.g.
(and many other types)
The text was updated successfully, but these errors were encountered: