diff --git a/.github/workflows/rust.yml b/.github/workflows/rust.yml index 72614fa..2a83694 100644 --- a/.github/workflows/rust.yml +++ b/.github/workflows/rust.yml @@ -61,6 +61,10 @@ jobs: if: ${{ !matrix.no_std }} run: cargo test --verbose + - name: Cargo test no default features + if: matrix.nightly + run: cargo test --verbose --no-default-features + - name: Cargo test all features if: matrix.nightly run: cargo test --verbose --all-features @@ -69,6 +73,10 @@ jobs: if: matrix.nightly run: cargo doc --all-features --verbose + - name: Cargo bench no default features + if: matrix.nightly + run: cargo clean && cargo bench --verbose --no-default-features + - name: Cargo bench all features if: matrix.nightly run: cargo clean && cargo bench --verbose --all-features diff --git a/Cargo.lock b/Cargo.lock index 08d6e29..a2ff25d 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -20,6 +20,12 @@ dependencies = [ "cc", ] +[[package]] +name = "allocator-api2" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c880a97d28a3681c0267bd29cff89621202715b065127cd445fa0f0fe0aa2880" + [[package]] name = "anes" version = "0.1.6" @@ -639,6 +645,7 @@ checksum = "0c790de23124f9ab44544d7ac05d60440adc586479ce501c1d6d7da3cd8c9cf5" name = "smallvec" version = "2.0.0-alpha.13" dependencies = [ + "allocator-api2", "arbitrary", "borsh", "bytes", diff --git a/src/lib.rs b/src/lib.rs index 6197324..2c222be 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -5,15 +5,14 @@ // except according to those terms. #![doc = include_str!("../README.md")] -#![no_std] +#![cfg_attr(not(feature = "std"), no_std)] #![cfg_attr(docsrs, feature(doc_cfg))] #![cfg_attr(feature = "specialization", allow(incomplete_features))] #![cfg_attr(feature = "specialization", feature(specialization, trusted_len))] #![cfg_attr(feature = "may_dangle", feature(dropck_eyepatch))] +#![cfg_attr(not(feature = "allocator-api2"), feature(allocator_api))] extern crate alloc; -#[cfg(feature = "std")] -extern crate std; #[cfg(feature = "borsh")] mod borsh; @@ -33,7 +32,7 @@ mod specialization; mod taggedlen; #[cfg(not(feature = "allocator-api2"))] -use alloc::{ +use alloc::alloc::{ Allocator, Global };