Skip to content

Commit 97e33c5

Browse files
committed
MAINT: Fix rayon, serde, blas features for no-std changes
rayon: implies std, because threads to serde: works fine without std blas: works fine without std if we use libc (libc is a new dependency for this feature flag, but it's already used by blas transitively). A slight hack is used for rayon (renaming the dependency) because we need to use a feature flag to enable std in this crate too.
1 parent 45966a0 commit 97e33c5

File tree

5 files changed

+17
-17
lines changed

5 files changed

+17
-17
lines changed

Cargo.toml

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,18 @@ num-integer = { version = "0.1.39", default-features = false }
3232
num-traits = { version = "0.2", default-features = false }
3333
num-complex = { version = "0.3", default-features = false }
3434

35-
rayon = { version = "1.0.3", optional = true }
35+
# Use via the `rayon` crate feature!
36+
rayon_ = { version = "1.0.3", optional = true, package = "rayon" }
3637

3738
approx = { version = "0.4", optional = true , default-features = false }
3839

3940
# Use via the `blas` crate feature!
4041
cblas-sys = { version = "0.1.4", optional = true, default-features = false }
4142
blas-src = { version = "0.6.1", optional = true, default-features = false }
43+
libc = { version = "0.2.82", optional = true }
4244

4345
matrixmultiply = { version = "0.2.0", default-features = false}
44-
serde = { version = "1.0", optional = true }
46+
serde = { version = "1.0", optional = true, default-features = false, features = ["alloc"] }
4547
rawpointer = { version = "0.2" }
4648

4749
[dev-dependencies]
@@ -55,7 +57,7 @@ default = ["std"]
5557

5658
# Enable blas usage
5759
# See README for more instructions
58-
blas = ["cblas-sys", "blas-src"]
60+
blas = ["cblas-sys", "blas-src", "libc"]
5961

6062
# Old name for the serde feature
6163
serde-1 = ["serde"]
@@ -68,6 +70,7 @@ test = ["test-blas-openblas-sys"]
6870
docs = ["approx", "serde", "rayon"]
6971

7072
std = ["num-traits/std", "matrixmultiply/std"]
73+
rayon = ["rayon_", "std"]
7174

7275
[profile.release]
7376
[profile.bench]

README.rst

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ your `Cargo.toml`.
5050

5151
- ``std``
5252

53-
- Rust Standard Library
53+
- Rust standard library (enabled by default)
5454

5555
- This crate can be used without the standard library by disabling the
5656
default `std` feature. To do so, use this in your `Cargo.toml`:
@@ -63,20 +63,18 @@ your `Cargo.toml`.
6363

6464
- ``serde``
6565

66-
- Optional, compatible with Rust stable
6766
- Enables serialization support for serde 1.x
6867

6968
- ``rayon``
7069

71-
- Optional, compatible with Rust stable
7270
- Enables parallel iterators, parallelized methods and ``par_azip!``.
71+
- Implies std
7372

7473
- ``blas``
7574

76-
- Optional and experimental, compatible with Rust stable
7775
- Enable transparent BLAS support for matrix multiplication.
7876
Uses ``blas-src`` for pluggable backend, which needs to be configured
79-
separately.
77+
separately (see below).
8078

8179
How to use with cargo
8280
---------------------

serialization-tests/Cargo.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@ default = ["ron"]
1515

1616
[dev-dependencies.serde]
1717
version = "1.0.100"
18+
default-features = false
1819

1920
[dev-dependencies.serde_json]
2021
version = "1.0.40"

src/lib.rs

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -70,27 +70,23 @@
7070
//! `Cargo.toml`.
7171
//!
7272
//! - `std`
73-
//! - Rust Standard Library
73+
//! - Rust standard library (enabled by default)
7474
//! - This crate can be used without the standard library by disabling the
7575
//! default `std` feature. To do so, use `default-features = false` in
7676
//! your `Cargo.toml`.
7777
//! - The `geomspace` `linspace` `logspace` `range` `std` `var` `var_axis`
78-
//! and `std_axis` methods are only available when `std` is
79-
//! enabled.
78+
//! and `std_axis` methods are only available when `std` is enabled.
8079
//! - `serde`
81-
//! - Optional, compatible with Rust stable
8280
//! - Enables serialization support for serde 1.x
8381
//! - `rayon`
84-
//! - Optional, compatible with Rust stable
8582
//! - Enables parallel iterators, parallelized methods and [`par_azip!`].
83+
//! - Implies std
8684
//! - `approx`
87-
//! - Optional, compatible with Rust stable
8885
//! - Enables implementations of traits from the [`approx`] crate.
8986
//! - `blas`
90-
//! - Optional and experimental, compatible with Rust stable
9187
//! - Enable transparent BLAS support for matrix multiplication.
9288
//! Uses ``blas-src`` for pluggable backend, which needs to be configured
93-
//! separately.
89+
//! separately (see the README).
9490
//!
9591
//! ## Documentation
9692
//!
@@ -1594,6 +1590,8 @@ where
15941590

15951591
// parallel methods
15961592
#[cfg(feature = "rayon")]
1593+
extern crate rayon_ as rayon;
1594+
#[cfg(feature = "rayon")]
15971595
pub mod parallel;
15981596

15991597
mod impl_1d;

src/linalg/impl_linalg.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@ use std::cmp;
1919
#[cfg(feature = "blas")]
2020
use std::mem::swap;
2121
#[cfg(feature = "blas")]
22-
use std::os::raw::c_int;
22+
use libc::c_int;
2323

2424
#[cfg(feature = "blas")]
2525
use cblas_sys as blas_sys;

0 commit comments

Comments
 (0)