diff --git a/dash/Cargo.toml b/dash/Cargo.toml index a69ed823a..06104c5d8 100644 --- a/dash/Cargo.toml +++ b/dash/Cargo.toml @@ -40,7 +40,7 @@ test-utils = [] # The no-std feature doesn't disable std - you need to turn off the std feature for that by disabling default. # Instead no-std enables additional features required for this crate to be usable without std. # As a result, both can be enabled without conflict. -std = ["secp256k1/std", "dashcore_hashes/std", "bech32/std", "internals/std"] +std = ["secp256k1/std", "dashcore_hashes/std", "bech32/std"] no-std = ["core2", "dashcore_hashes/alloc", "dashcore_hashes/core2", "secp256k1/alloc"] [package.metadata.docs.rs] diff --git a/hashes/Cargo.toml b/hashes/Cargo.toml index 77287370e..cf600e12f 100644 --- a/hashes/Cargo.toml +++ b/hashes/Cargo.toml @@ -14,8 +14,8 @@ exclude = ["tests", "contrib"] [features] default = ["std"] -std = ["alloc", "internals/std"] -alloc = ["internals/alloc"] +std = ["alloc"] +alloc = [] schemars = ["actual-schemars"] serde-std = ["serde/std"] x11 = ["rs-x11-hash"] diff --git a/internals/Cargo.toml b/internals/Cargo.toml index 2f7050875..5917b4254 100644 --- a/internals/Cargo.toml +++ b/internals/Cargo.toml @@ -14,8 +14,6 @@ exclude = ["tests", "contrib"] [features] default = [] -std = ["alloc"] -alloc = [] [package.metadata.docs.rs] all-features = true diff --git a/internals/src/hex/display.rs b/internals/src/hex/display.rs index 239debb80..1b82988e8 100644 --- a/internals/src/hex/display.rs +++ b/internals/src/hex/display.rs @@ -9,8 +9,6 @@ use core::fmt; use super::Case; use super::buf_encoder::{BufEncoder, OutBytes}; use crate::hex::buf_encoder::FixedLenBuf; -#[cfg(feature = "alloc")] -use crate::prelude::*; /// Extension trait for types that can be displayed as hex. /// @@ -34,7 +32,6 @@ pub trait DisplayHex: Copy + sealed::IsRef { /// A shorthand for `to_hex_string(Case::Lower)`, so that `Case` doesn't need to be imported. /// /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. - #[cfg(feature = "alloc")] fn to_lower_hex_string(self) -> String { self.to_hex_string(Case::Lower) } @@ -44,7 +41,6 @@ pub trait DisplayHex: Copy + sealed::IsRef { /// A shorthand for `to_hex_string(Case::Upper)`, so that `Case` doesn't need to be imported. /// /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. - #[cfg(feature = "alloc")] fn to_upper_hex_string(self) -> String { self.to_hex_string(Case::Upper) } @@ -52,7 +48,6 @@ pub trait DisplayHex: Copy + sealed::IsRef { /// Create a hex-encoded string. /// /// This may be faster than `.display_hex().to_string()` because it uses `reserve_suggestion`. - #[cfg(feature = "alloc")] fn to_hex_string(self, case: Case) -> String { let mut string = String::new(); self.append_hex_to_string(case, &mut string); @@ -63,7 +58,6 @@ pub trait DisplayHex: Copy + sealed::IsRef { /// /// This may be faster than `write!(string, "{:x}", self.display_hex())` because it uses /// `reserve_suggestion`. - #[cfg(feature = "alloc")] fn append_hex_to_string(self, case: Case, string: &mut String) { use fmt::Write; @@ -117,8 +111,7 @@ impl<'a> DisplayHex for &'a [u8] { } } -#[cfg(feature = "alloc")] -impl<'a> DisplayHex for &'a alloc::vec::Vec { +impl<'a> DisplayHex for &'a Vec { type Display = DisplayByteSlice<'a>; #[inline] @@ -274,67 +267,59 @@ where #[cfg(test)] mod tests { - #[cfg(feature = "alloc")] use super::*; - #[cfg(feature = "alloc")] - mod alloc { - use super::*; + fn check_encoding(bytes: &[u8]) { + use core::fmt::Write; - fn check_encoding(bytes: &[u8]) { - use core::fmt::Write; - - let s1 = bytes.to_lower_hex_string(); - let mut s2 = String::with_capacity(bytes.len() * 2); - for b in bytes { - write!(s2, "{:02x}", b).unwrap(); - } - assert_eq!(s1, s2); - } - - #[test] - fn empty() { - check_encoding(b""); + let s1 = bytes.to_lower_hex_string(); + let mut s2 = String::with_capacity(bytes.len() * 2); + for b in bytes { + write!(s2, "{:02x}", b).unwrap(); } + assert_eq!(s1, s2); + } - #[test] - fn single() { - check_encoding(b"*"); - } + #[test] + fn empty() { + check_encoding(b""); + } - #[test] - fn two() { - check_encoding(b"*x"); - } + #[test] + fn single() { + check_encoding(b"*"); + } - #[test] - fn just_below_boundary() { - check_encoding(&[42; 512]); - } + #[test] + fn two() { + check_encoding(b"*x"); + } - #[test] - fn just_above_boundary() { - check_encoding(&[42; 513]); - } + #[test] + fn just_below_boundary() { + check_encoding(&[42; 512]); + } - #[test] - fn just_above_double_boundary() { - check_encoding(&[42; 1025]); - } + #[test] + fn just_above_boundary() { + check_encoding(&[42; 513]); + } - #[test] - fn fmt_exact_macro() { - use crate::alloc::string::ToString; + #[test] + fn just_above_double_boundary() { + check_encoding(&[42; 1025]); + } - struct Dummy([u8; 32]); + #[test] + fn fmt_exact_macro() { + struct Dummy([u8; 32]); - impl fmt::Display for Dummy { - fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { - fmt_hex_exact!(f, 32, &self.0, Case::Lower) - } + impl fmt::Display for Dummy { + fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { + fmt_hex_exact!(f, 32, &self.0, Case::Lower) } - - assert_eq!(Dummy([42; 32]).to_string(), "2a".repeat(32)); } + + assert_eq!(Dummy([42; 32]).to_string(), "2a".repeat(32)); } } diff --git a/internals/src/lib.rs b/internals/src/lib.rs index c4f439dc8..8c31cffb1 100644 --- a/internals/src/lib.rs +++ b/internals/src/lib.rs @@ -7,24 +7,11 @@ //! [rust-dash](https://github.com/rust-dashcore) ecosystem. //! -#![no_std] // Experimental features we need. #![cfg_attr(docsrs, feature(doc_auto_cfg))] // Coding conventions #![warn(missing_docs)] -#[cfg(feature = "alloc")] -extern crate alloc; - -#[cfg(feature = "std")] -extern crate std; - pub mod error; pub mod hex; pub mod macros; - -/// Mainly reexports based on features. -pub(crate) mod prelude { - #[cfg(feature = "alloc")] - pub(crate) use alloc::string::String; -}