diff --git a/Cargo.toml b/Cargo.toml index de78a4e..983c53e 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -27,8 +27,8 @@ default = ["std"] std = [] # Reduce code size at the cost of performance. compact = [] -# Do not use a system allocator anywhere. -no_alloc = [] +# Use the system allocator. +alloc = [] # Add support for nightly-only features. nightly = [] diff --git a/ci/test.sh b/ci/test.sh index 206e3f4..ec94778 100755 --- a/ci/test.sh +++ b/ci/test.sh @@ -18,9 +18,8 @@ fi # Test various feature combinations. FEATURES=( "compact" - # TODO(ahuszagh) Change to alloc. - "no_alloc" - "compact,no_alloc" + "alloc" + "compact,alloc" ) check() { diff --git a/etc/correctness/Cargo.toml b/etc/correctness/Cargo.toml index 85b9e7d..93545ea 100644 --- a/etc/correctness/Cargo.toml +++ b/etc/correctness/Cargo.toml @@ -23,7 +23,7 @@ toml = "0.5" default = ["std"] std = ["minimal-lexical/std"] compact = ["minimal-lexical/compact"] -no_alloc = ["minimal-lexical/no_alloc"] +alloc = ["minimal-lexical/alloc"] nightly = ["minimal-lexical/nightly"] # Special testing binaries for the runtests.py scripts. diff --git a/fuzz/Cargo.toml b/fuzz/Cargo.toml index 9cd677c..cf56040 100644 --- a/fuzz/Cargo.toml +++ b/fuzz/Cargo.toml @@ -20,7 +20,7 @@ libfuzzer-sys = "0.2.0" default = ["std"] std = ["minimal-lexical/std"] compact = ["minimal-lexical/compact"] -no_alloc = ["minimal-lexical/no_alloc"] +alloc = ["minimal-lexical/alloc"] nightly = ["minimal-lexical/nightly"] [profile.release] diff --git a/scripts/check.sh b/scripts/check.sh index 4bbefac..7a630c3 100755 --- a/scripts/check.sh +++ b/scripts/check.sh @@ -13,5 +13,5 @@ cd "$script_dir"/.. cargo +nightly fmt -- --check cargo +nightly clippy --no-default-features -- --deny warnings cargo +nightly clippy --features=compact -- --deny warnings -cargo +nightly clippy --features=no_alloc -- --deny warnings +cargo +nightly clippy --features=alloc -- --deny warnings diff --git a/src/bigint.rs b/src/bigint.rs index 6a77488..d1d5027 100644 --- a/src/bigint.rs +++ b/src/bigint.rs @@ -4,10 +4,10 @@ #![doc(hidden)] -#[cfg(not(feature = "no_alloc"))] +#[cfg(feature = "alloc")] use crate::heapvec::HeapVec; use crate::num::Float; -#[cfg(feature = "no_alloc")] +#[cfg(not(feature = "alloc"))] use crate::stackvec::StackVec; #[cfg(not(feature = "compact"))] use crate::table::{LARGE_POW5, LARGE_POW5_STEP}; @@ -23,10 +23,10 @@ pub const BIGINT_BITS: usize = 4000; /// The number of limbs for the bigint. pub const BIGINT_LIMBS: usize = BIGINT_BITS / LIMB_BITS; -#[cfg(not(feature = "no_alloc"))] +#[cfg(feature = "alloc")] pub type VecType = HeapVec; -#[cfg(feature = "no_alloc")] +#[cfg(not(feature = "alloc"))] pub type VecType = StackVec; /// Storage for a big integer type. diff --git a/src/heapvec.rs b/src/heapvec.rs index 968bb0b..0359260 100644 --- a/src/heapvec.rs +++ b/src/heapvec.rs @@ -1,6 +1,6 @@ //! Simple heap-allocated vector. -#![cfg(not(feature = "no_alloc"))] +#![cfg(feature = "alloc")] #![doc(hidden)] use crate::bigint; diff --git a/src/lib.rs b/src/lib.rs index 8c1092c..75f9234 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -40,7 +40,7 @@ #![cfg_attr(feature = "lint", warn(unsafe_op_in_unsafe_fn))] #![cfg_attr(not(feature = "std"), no_std)] -#[cfg(all(not(feature = "no_alloc"), not(feature = "std")))] +#[cfg(all(feature = "alloc", not(feature = "std")))] extern crate alloc; pub mod bellerophon; diff --git a/src/parse.rs b/src/parse.rs index 8fe4590..9349699 100644 --- a/src/parse.rs +++ b/src/parse.rs @@ -134,7 +134,7 @@ where /// /// Although passing garbage input will not cause memory safety issues, /// it is very likely to cause a panic with a large number of digits, or -/// in debug mode. The big-integer arithmetic with the `no_alloc` feature +/// in debug mode. The big-integer arithmetic without the `alloc` feature /// assumes a maximum, fixed-width input, which assumes at maximum a /// value of `10^(769 + 342)`, or ~4000 bits of storage. Passing in /// nonsensical digits may require up to ~6000 bits of storage, which will diff --git a/src/stackvec.rs b/src/stackvec.rs index 2b406f9..d9bc259 100644 --- a/src/stackvec.rs +++ b/src/stackvec.rs @@ -1,6 +1,6 @@ //! Simple stack-allocated vector. -#![cfg(feature = "no_alloc")] +#![cfg(not(feature = "alloc"))] #![doc(hidden)] use crate::bigint; diff --git a/tests/stackvec.rs b/tests/stackvec.rs index 223e406..d5587f2 100644 --- a/tests/stackvec.rs +++ b/tests/stackvec.rs @@ -1,7 +1,7 @@ use minimal_lexical::bigint; -#[cfg(not(feature = "no_alloc"))] +#[cfg(feature = "alloc")] pub use minimal_lexical::heapvec::HeapVec as VecType; -#[cfg(feature = "no_alloc")] +#[cfg(not(feature = "alloc"))] pub use minimal_lexical::stackvec::StackVec as VecType; pub fn vec_from_u32(x: &[u32]) -> VecType {