From 3639c99b0f280dab3c13339b968680a7ffca615e Mon Sep 17 00:00:00 2001 From: Ed Page Date: Tue, 29 Mar 2022 06:54:54 -0500 Subject: [PATCH] fix!: Add 'std' feature This will allow us to add no_std support without breaking compatibility --- .github/workflows/ci.yml | 6 +++--- .github/workflows/rust-next.yml | 4 ++-- Cargo.toml | 5 ++++- src/lib.rs | 3 +++ 4 files changed, 12 insertions(+), 6 deletions(-) diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml index e296cc9..4160866 100644 --- a/.github/workflows/ci.yml +++ b/.github/workflows/ci.yml @@ -91,7 +91,7 @@ jobs: - name: All features run: cargo test --target ${{ matrix.target }} --workspace --all-features - name: No-default features - run: cargo test --target ${{ matrix.target }} --workspace --no-default-features + run: cargo test --target ${{ matrix.target }} --workspace --no-default-features --features std miri: name: Miri runs-on: ubuntu-latest @@ -113,7 +113,7 @@ jobs: - name: All features run: cargo miri test --all-features - name: No-default features - run: cargo miri test --no-default-features + run: cargo miri test --no-default-features --features std msrv: name: "Check MSRV: 1.59.0" runs-on: ubuntu-latest @@ -132,7 +132,7 @@ jobs: - name: All features run: cargo check --workspace --all-targets --all-features - name: No-default features - run: cargo check --workspace --all-targets --no-default-features + run: cargo check --workspace --all-targets --no-default-features --features std docs: name: Docs runs-on: ubuntu-latest diff --git a/.github/workflows/rust-next.yml b/.github/workflows/rust-next.yml index cdb11a9..8f895e6 100644 --- a/.github/workflows/rust-next.yml +++ b/.github/workflows/rust-next.yml @@ -29,7 +29,7 @@ jobs: - name: All features run: cargo test --workspace --all-features - name: No-default features - run: cargo test --workspace --no-default-features + run: cargo test --workspace --no-default-features --features std miri: name: Miri runs-on: ubuntu-latest @@ -51,7 +51,7 @@ jobs: - name: All features run: cargo miri test --all-features - name: No-default features - run: cargo miri test --no-default-features + run: cargo miri test --no-default-features --features std rustfmt: name: rustfmt strategy: diff --git a/Cargo.toml b/Cargo.toml index da6ec9d..facf44f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -34,7 +34,10 @@ pre-release-replacements = [ ] [features] -default = ["unsafe"] +default = ["std", "unsafe"] + +## Allow use of `std` +std = [] ## O(1) clone support arc = [] diff --git a/src/lib.rs b/src/lib.rs index 151597e..8b6edf3 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -22,6 +22,9 @@ #![cfg_attr(feature = "document-features", doc = document_features::document_features!())] #![cfg_attr(feature = "safe", forbid(unsafe_code))] +#[cfg(not(feature = "std"))] +compile_error!("`std` feature is required; reserved for future `no_std` support"); + mod stack; mod string; mod string_cow;