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

Implement no_std support with simplified to_string #33

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

AdnoC
Copy link

@AdnoC AdnoC commented Aug 23, 2023

My attempt at resolving #3.

Some things had to change. Firstly, in order to support alignment format specifiers we would have to write to a buffer and then Formatter::pad that. So we do not support alignment in no_std. I can add that if that is a requirement, but I felt that implementing the buffer would be a lot.

Also, the algorithm used to select the correct units had to change. no_std does not have access to complex math like ln. So we just manually check which unit is correct and go from there.

Nothing should be changed when std is enabled. These things are conditionally changed when the std feature is disabled.

If you test with cargo test --no-default-features it will run all the tests that can be run with no_std.

Oh! Also I put aside the parsing element. None of that is enabled when not using the standard library.

@hyunsik
Copy link
Collaborator

hyunsik commented Sep 6, 2023

I'm sorry for a late review. I'll review asap by this week.

@AdnoC
Copy link
Author

AdnoC commented Sep 7, 2023

Rebased off of master because there were merge conflicts.

The example showing the use of to_string_as was breaking no-std tests (because there is no String without std), so I had to update the doc comment to only render when std is enabled.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants