mhogrefe / malachite

An arbitrary-precision arithmetic library for Rust.
GNU Lesser General Public License v3.0
448 stars 17 forks source link

`no_std` support #10

Closed indietyp closed 7 months ago

indietyp commented 1 year ago

I am currently working on an embedded project where the std isn't available. I understand that for numbers larger than $2^{64}$, numbers will need to allocate, but alloc is available on my platform.

After a cursory at the library and import statements, it seems a conversion to a no-std compatible library would be possible?

I this something this library would be willing to support?

I'd be happy to create a PR converting the project to no-std!

mhogrefe commented 1 year ago

Thank you for the suggestion and your PR offer!

I think this would a useful change. After doing some quick research into no-std, converting Malachite to it does seem possible. Malachite uses Vec very often and occasionally uses Box, but the alloc crate lets you use those. Malachite also uses HashMap in a few places, but it should be possible to use the hashbrown HashMap instead. The test code, as well as anything enabled with bin_util and test_util, doesn't need to be converted.

Please go ahead with the PR, and let me know if you run into any issues.

SeriousBusiness100 commented 1 year ago

There may be difficulties with hashbrown: https://www.reddit.com/r/rust/comments/shw3gj/seeking_opinions_on_supporting_no_std_by/

indietyp commented 1 year ago

I am sorry that not much has moved in this regard. I started to work on this, but then the needs of the particular no-std project shifted to no longer require this library and I kind of forgot to complete and submit a PR 😅 Sorry!