Skip to content

Commit

Permalink
fix no-std feature
Browse files Browse the repository at this point in the history
  • Loading branch information
knickish committed Oct 22, 2023
1 parent a216438 commit 287ecde
Show file tree
Hide file tree
Showing 6 changed files with 49 additions and 4 deletions.
23 changes: 23 additions & 0 deletions .github/workflows/rust.yml
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,29 @@ jobs:
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions-rs/cargo@v1
with:
command: test

test_no_std:
name: Test No Std
runs-on: ${{ matrix.config.os }}
strategy:
fail-fast: false
matrix:
config:
- { os: ubuntu-latest, target: 'x86_64-unknown-linux-gnu' }

steps:
- uses: actions/checkout@v2
- uses: actions-rs/toolchain@v1
with:
toolchain: nightly
target: ${{ matrix.config.target }}
override: true
- uses: actions-rs/cargo@v1
with:
command: test
- uses: actions-rs/cargo@v1
with:
command: test
Expand Down
2 changes: 1 addition & 1 deletion src/serde_bin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -543,7 +543,7 @@ where

impl<K, V> DeBin for HashMap<K, V>
where
K: DeBin + std::cmp::Eq + std::hash::Hash,
K: DeBin + core::cmp::Eq + Hash,
V: DeBin,
{
fn de_bin(o: &mut usize, d: &[u8]) -> Result<Self, DeBinErr> {
Expand Down
8 changes: 7 additions & 1 deletion tests/bin.rs
Original file line number Diff line number Diff line change
@@ -1,9 +1,15 @@
use std::{
array,
collections::{BTreeSet, HashMap, HashSet, LinkedList},
collections::{BTreeSet, LinkedList},
sync::atomic::AtomicBool,
};

#[cfg(feature = "no_std")]
use hashbrown::{HashMap, HashSet};

#[cfg(not(feature = "no_std"))]
use std::collections::{HashMap, HashSet};

use nanoserde::{DeBin, SerBin};

#[test]
Expand Down
8 changes: 7 additions & 1 deletion tests/json.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use nanoserde::{DeJson, SerJson};

use std::{
collections::{BTreeSet, HashMap, HashSet, LinkedList},
collections::{BTreeSet, LinkedList},
sync::atomic::AtomicBool,
};

#[cfg(feature = "no_std")]
use hashbrown::{HashMap, HashSet};

#[cfg(not(feature = "no_std"))]
use std::collections::{HashMap, HashSet};

#[test]
fn de() {
#[derive(DeJson)]
Expand Down
8 changes: 7 additions & 1 deletion tests/ron.rs
Original file line number Diff line number Diff line change
@@ -1,10 +1,16 @@
use nanoserde::{DeRon, SerRon};

use std::{
collections::{BTreeSet, HashMap, HashSet, LinkedList},
collections::{BTreeSet, LinkedList},
sync::atomic::AtomicBool,
};

#[cfg(feature = "no_std")]
use hashbrown::{HashMap, HashSet};

#[cfg(not(feature = "no_std"))]
use std::collections::{HashMap, HashSet};

#[test]
fn ron_de() {
#[derive(DeRon)]
Expand Down
4 changes: 4 additions & 0 deletions tests/ser_de.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
use nanoserde::{DeBin, DeJson, DeRon, SerBin, SerJson, SerRon};

#[cfg(feature = "no_std")]
use hashbrown::HashMap;

#[cfg(not(feature = "no_std"))]
use std::collections::HashMap;

#[test]
Expand Down

0 comments on commit 287ecde

Please sign in to comment.