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

Add dec!() macro by example #692

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

daniel-pfeiffer
Copy link

As discussed, here is a cleaned up, further optimised and integrated new implementation of dec!. It is a completely const and compile-time drop in replacement. This requires Rust 1.79.

Your Result<…String…> is not destructible, i.e. not usable in const. Therefore the new parser has its own Result, that can be transparently converted by ?. This also required splitting try_from_i128_with_scale which thus became simpler.

For now the parser does only exact in i128. Rounding should be addable, if you want to switch parsing completely to this.

Being generic on a smaller type doesn’t currently seem possible in const. Should a benchmark show this to be slower than parsing into u64, the old and new parsers might continue to coexist, till a solution is found.

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

Successfully merging this pull request may close these issues.

1 participant