Bitshala-Incubator / rust-coinselect

A blockchain-agnostic coinselection library built in rust.
MIT License
8 stars 17 forks source link

Support For No-std #36

Open aruokhai opened 1 month ago

aruokhai commented 1 month ago

Objective

The addition of no_std support would effectively improve the range of usage of the coinselect library. It is quite advantageous at this point that very little external dependencies exist , in this light it would be quite straight forward for the support of no_std environment to be implemented.

Changes Required

A require change is the inclusion of the attribute in the lib.rs file

#![no_std]

#[cfg(feature = "std")]
extern crate std;

which ensures that no_std is the default state.

In the toml file we need to ensure no_std for the rand dep is recognised with such lines :

[dependencies]
rand = { version = "0.8.5", default-features = false , features = ["alloc"] }

[features]
std = ["rand/std"]

This is also required for functions that requires std functionalities

#[cfg(feature = "std")]

pub fn function_that_requires_std() {
    // ...
}
aruokhai commented 1 month ago

I would begin working on it which i believe the code might clarify future questions.