gioser

tawasuyu/taffy

A high performance rust-powered UI layout library

Rust 497HTML 254C 19JavaScript 81329 Definiciones

Add CI jobs for checking and testing with no default features (#36)

* Add GitHub Actions workflows for checking and testing with no default features

* Convert heapless constants to Rust constants

* Migrate arrayvec types to constant generics

* Remove arrayvec::Array trait usage

* Add CI with --no-default-features --features-alloc flags

* Remove cargo check jobs from CI

The test suits will still catch errors here, this many jobs make the CI too noisy.

d703163ffdc201c2718f03b1b4f10e01ea4b976a · por TimJentzsch · (hace 4 años) · padre c7bbb824c · ver el árbol en este commit

Delta semántico · 11

src/sys.rs

2 archivos · +29 −18

diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml
index ca05d5b97..e226a60d3 100644
--- a/.github/workflows/ci.yml
+++ b/.github/workflows/ci.yml
@@ -3,8 +3,8 @@ on: [push, pull_request]
 name: Continuous integration
 
 jobs:
-  check:
-    name: Check
+  test-features-none:
+    name: "Test Suite [Features: None]"
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
@@ -15,10 +15,25 @@ jobs:
           override: true
       - uses: actions-rs/cargo@v1
         with:
-          command: check
+          command: test
+          args: --no-default-features
+
+  test-features-default:
+    name: "Test Suite [Features: Default]"
+    runs-on: ubuntu-latest
+    steps:
+      - uses: actions/checkout@v2
+      - uses: actions-rs/toolchain@v1
+        with:
+          profile: minimal
+          toolchain: stable
+          override: true
+      - uses: actions-rs/cargo@v1
+        with:
+          command: test
 
-  test:
-    name: Test Suite
+  test-features-alloc:
+    name: "Test Suite [Features: alloc]"
     runs-on: ubuntu-latest
     steps:
       - uses: actions/checkout@v2
@@ -30,6 +45,7 @@ jobs:
       - uses: actions-rs/cargo@v1
         with:
           command: test
+          args: --no-default-features --features alloc
 
   fmt:
     name: Rustfmt
diff --git a/src/sys.rs b/src/sys.rs
index acaf20ce1..ef8d5b5e5 100644
--- a/src/sys.rs
+++ b/src/sys.rs
@@ -57,16 +57,14 @@ mod alloc {
 
 #[cfg(all(not(feature = "alloc"), not(feature = "std")))]
 mod core {
-    use typenum::marker_traits::Unsigned;
+    const MAX_NODE_COUNT: usize = 256;
+    const MAX_CHILD_COUNT: usize = 16;
+    const MAX_PARENTS_COUNT: usize = 1;
 
-    type MaxNodeCount = heapless::consts::U256;
-    type MaxChildCount = heapless::consts::U16;
-    type MaxParentsCount = heapless::consts::U1;
-
-    pub type Map<K, V> = ::heapless::FnvIndexMap<K, V, MaxNodeCount>;
-    pub type Vec<A> = ::arrayvec::ArrayVec<[A; MaxNodeCount::USIZE]>;
-    pub type ChildrenVec<A> = ::arrayvec::ArrayVec<[A; MaxChildCount::USIZE]>;
-    pub type ParentsVec<A> = ::arrayvec::ArrayVec<[A; MaxParentsCount::USIZE]>;
+    pub type Map<K, V> = ::heapless::FnvIndexMap<K, V, MAX_NODE_COUNT>;
+    pub type Vec<A> = ::arrayvec::ArrayVec<A, MAX_NODE_COUNT>;
+    pub type ChildrenVec<A> = ::arrayvec::ArrayVec<A, MAX_CHILD_COUNT>;
+    pub type ParentsVec<A> = ::arrayvec::ArrayVec<A, MAX_PARENTS_COUNT>;
 
     pub fn new_map_with_capacity<K, V>(_capacity: usize) -> Map<K, V>
     where
@@ -75,10 +73,7 @@ mod core {
         Map::new()
     }
 
-    pub fn new_vec_with_capacity<T, A>(_capacity: usize) -> ::arrayvec::ArrayVec<A>
-    where
-        A: ::arrayvec::Array<Item = T>,
-    {
+    pub fn new_vec_with_capacity<A, const CAP: usize>(_capacity: usize) -> ::arrayvec::ArrayVec<A, CAP> {
         ::arrayvec::ArrayVec::new()
     }