primitives: Fix alloc feature

We have an `alloc` feature but we are unconditionally using
`extern crate alloc`, this is broken - clearly we need to add a `no-std`
build for `primitives` in CI.

Feature gate the `alloc` crate.

While we are at it just pull types in from `alloc` in the `prelude` - I
have no idea why we do not do this in `bitcoin`?
This commit is contained in:
Tobin C. Harding 2024-08-08 10:57:38 +10:00
parent 000661360e
commit 3b5bcd0983
No known key found for this signature in database
GPG Key ID: 40BF9E4C269D6607
1 changed files with 2 additions and 4 deletions

View File

@ -18,6 +18,7 @@
#![allow(clippy::manual_range_contains)] // More readable than clippy's format. #![allow(clippy::manual_range_contains)] // More readable than clippy's format.
#![allow(clippy::needless_borrows_for_generic_args)] // https://github.com/rust-lang/rust-clippy/issues/12454 #![allow(clippy::needless_borrows_for_generic_args)] // https://github.com/rust-lang/rust-clippy/issues/12454
#[cfg(feature = "alloc")]
extern crate alloc; extern crate alloc;
#[cfg(feature = "std")] #[cfg(feature = "std")]
@ -44,9 +45,6 @@ pub use self::sequence::Sequence;
#[rustfmt::skip] #[rustfmt::skip]
#[allow(unused_imports)] #[allow(unused_imports)]
mod prelude { mod prelude {
#[cfg(all(not(feature = "std"), not(test)))] #[cfg(feature = "alloc")]
pub use alloc::string::ToString; pub use alloc::string::ToString;
#[cfg(any(feature = "std", test))]
pub use std::string::ToString;
} }