Skip to content

Commit

Permalink
Add the ability to work in no-std (optionally with alloc) (#132)
Browse files Browse the repository at this point in the history
By default, the `std` feature is enabled, but with disable-default-features, it can now be either no-std/no-alloc.

This did involve a **breaking change** with the serialization traits, to allow no-alloc serialization.

Serialize/Deserialize traits were sealed, and most functions were hidden

Per [updated guidance][1], it is recommended to commit the Cargo.lock, even for libraries, so this removes it from the gitignore, and adds it.

Fixes #131

[1]: https://blog.rust-lang.org/2023/08/29/committing-lockfiles.html
  • Loading branch information
Dr-Emann authored Jun 25, 2024
2 parents 457e7c9 + 57ef1a7 commit f1a9af1
Show file tree
Hide file tree
Showing 33 changed files with 1,721 additions and 415 deletions.
42 changes: 13 additions & 29 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,18 +8,15 @@ on:
branches:
- master

env:
RUSTFLAGS: -A warnings

jobs:
test:
name: Test on ${{ matrix.os }} using Rust ${{ matrix.rust }} with bindgen features '${{ matrix.cargo_features }}'
name: Test on ${{ matrix.os }} using Rust ${{ matrix.rust }} with features '${{ matrix.cargo_features }}'
runs-on: ${{ matrix.os }}
strategy:
matrix:
os: [ubuntu-latest, windows-latest, macos-latest]
rust: [stable, nightly]
cargo_features: ['']
cargo_features: ['', 'alloc', 'default']

steps:
- uses: hecrj/setup-rust-action@v2
Expand All @@ -44,33 +41,20 @@ jobs:
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly'

- name: Cargo clippy
run: cargo +${{ matrix.rust }} clippy --all-targets --workspace --features "${{ matrix.cargo_features }}"
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' && matrix.cargo_features != ''

- name: Cargo clippy
run: cargo +${{ matrix.rust }} clippy --all-targets --workspace
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' && matrix.cargo_features == ''

- name: Build
run: cargo +${{ matrix.rust }} build --features "${{ matrix.cargo_features }}"
if: matrix.cargo_features != ''

- name: Build
run: cargo +${{ matrix.rust }} build
if: matrix.cargo_features == ''

- name: Test
run: cargo +${{ matrix.rust }} test --features "${{ matrix.cargo_features }}"
if: matrix.cargo_features != ''
run: cargo +${{ matrix.rust }} clippy --all-targets --workspace --no-default-features --features "${{ matrix.cargo_features }}"
if: matrix.os == 'ubuntu-latest' && matrix.rust == 'nightly' && matrix.cargo_features == 'default'

- name: Test
run: cargo +${{ matrix.rust }} test
if: matrix.cargo_features == ''
run: cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}"

- name: Benchmark
if: matrix.rust == 'nightly'
run: cargo +${{ matrix.rust }} bench
run: cargo +${{ matrix.rust }} bench --no-default-features --features "${{ matrix.cargo_features }}"
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default'

- name: Minimal versions
if: matrix.rust == 'nightly'
run: cargo +${{ matrix.rust }} -Zdirect-minimal-versions test
run: cargo +${{ matrix.rust }} -Zdirect-minimal-versions test --no-default-features --features "${{ matrix.cargo_features }}"
if: matrix.rust == 'nightly' && matrix.cargo_features == 'default'

- name: Updated versions
run: cargo update && cargo +${{ matrix.rust }} test --no-default-features --features "${{ matrix.cargo_features }}"
if: matrix.rust == 'stable' && matrix.cargo_features == 'default'
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
target
Cargo.lock
.DS_Store
.idea
Loading

0 comments on commit f1a9af1

Please sign in to comment.