Skip to content

Commit 8dc1350

Browse files
committed
Add alloc feature
1 parent 3fb4ae3 commit 8dc1350

File tree

3 files changed

+3
-3
lines changed

3 files changed

+3
-3
lines changed

Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ resolver = "2"
1717
[features]
1818
default = ["std", "derive", "multihash-impl", "secure-hashes"]
1919
std = ["unsigned-varint/std", "multihash-derive/std"]
20+
alloc = []
2021
multihash-impl = ["derive"]
2122
derive = ["multihash-derive"]
2223
arb = ["quickcheck", "rand"]

src/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
#![deny(missing_docs)]
5353
#![cfg_attr(not(feature = "std"), no_std)]
5454

55-
#[cfg(not(feature = "std"))]
55+
#[cfg(all(not(feature = "std"), feature = "alloc"))]
5656
#[macro_use]
5757
extern crate alloc;
5858

src/multihash.rs

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use crate::hasher::{Digest, Size};
22
use crate::Error;
3-
#[cfg(feature = "alloc")]
3+
#[cfg(all(not(feature = "std"), feature = "alloc"))]
44
use alloc::vec::Vec;
55
use core::convert::TryFrom;
66

@@ -160,7 +160,6 @@ impl<S: Size> Multihash<S> {
160160
write_multihash(w, self.code(), self.size(), self.digest())
161161
}
162162

163-
164163
#[cfg(any(feature = "std", feature = "alloc"))]
165164
/// Returns the bytes of a multihash.
166165
pub fn to_bytes(&self) -> Vec<u8> {

0 commit comments

Comments
 (0)