Skip to content

Commit

Permalink
Add force-generic feature flag
Browse files Browse the repository at this point in the history
  • Loading branch information
DaniPopes committed Aug 30, 2023
1 parent b10b6d7 commit dc44e88
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 4 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,10 @@ jobs:

- run: cargo build
- run: cargo test
- run: cargo test --release
- run: cargo build --no-default-features
- run: cargo test --tests --no-default-features
- run: cargo test --tests --no-default-features --release --all-features
- run: cargo test --tests --no-default-features --features force-generic
- run: cargo test --tests --no-default-features --features nightly,portable-simd
if: matrix.rust == 'nightly'
- run: cargo bench --no-run
if: matrix.rust == 'nightly'
Expand All @@ -57,7 +57,7 @@ jobs:
fail-fast: false
matrix:
target: [x86_64-unknown-linux-gnu, aarch64-unknown-linux-gnu]
flags: [--no-default-features, "", --all-features]
flags: [--no-default-features, "", --all-features, --features force-generic]
exclude:
# miri doesn't implement neon intrinsics.
- target: aarch64-unknown-linux-gnu
Expand Down
3 changes: 3 additions & 0 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,9 @@ default = ["std"]
std = ["hex?/std", "serde?/std", "alloc"]
alloc = ["hex?/alloc", "serde?/alloc"]

# Forces generic implementation, overriding any specialized implementation (e.g. x86 or aarch64)
force-generic = []

# Serde support. Use with `#[serde(with = "const_hex")]`
serde = ["hex?/serde", "dep:serde"]

Expand Down
4 changes: 3 additions & 1 deletion src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,9 @@ use alloc::{string::String, vec::Vec};

// The main encoding and decoding functions.
cfg_if! {
if #[cfg(feature = "portable-simd")] {
if #[cfg(feature = "force-generic")] {
use generic as imp;
} else if #[cfg(feature = "portable-simd")] {
mod portable_simd;
use portable_simd as imp;
} else if #[cfg(any(target_arch = "x86", target_arch = "x86_64"))] {
Expand Down

0 comments on commit dc44e88

Please sign in to comment.