-
Notifications
You must be signed in to change notification settings - Fork 6
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
Add Display
and DisplayAlternative
wrapper types
#19
Conversation
Alternative naming could be: |
Hey, thanks for the great explanation. I'm not against adding this. I left a few comments so let me know what you think and if you want to do these changes yourself. Thanks! |
@fbernier reworked! |
Much cleaner, thanks! Cutting a release soon. |
I ended up reworking things a bit. I replaced Released as 2.2.0 Thanks again and let me know if I missed anything |
Follows #16, #17
Motivation
Applying the
base62::encode_fmt()
in my codebases, I've found that it doesn't play smooth with macro-based or non-transparent APIs (likederive_more::Display
orthiserror::Error
).Consider the code before applying #17:
This code now should be written "by hand", since
base62::encode()
cannot be substituted withbase62::encode_fmt()
trivially here.Solution
This PR introduces two functions:
base62::fmt()
andbase62::fmt_alt()
. They allow applyingbase62
encoding easily in anyformat!()
-like expressions, still avoiding unnecessary allocations.