From f35cce229ed2bb0e44e2e443cda6b6a0bae89e7e Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 May 2018 17:26:38 -0700 Subject: [PATCH 1/4] Always use #![no_std], and declare std when enabled --- src/lib.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 552051c..47a3bfa 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -18,9 +18,9 @@ #![deny(unconditional_recursion)] -#![cfg_attr(not(feature = "std"), no_std)] +#![no_std] #[cfg(feature = "std")] -extern crate core; +extern crate std; use core::ops::{Add, Sub, Mul, Div, Rem}; use core::ops::{AddAssign, SubAssign, MulAssign, DivAssign, RemAssign}; From 817ef9478490fc60f368502716587df5a781141c Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 May 2018 17:27:33 -0700 Subject: [PATCH 2/4] Add the no-std crate category --- Cargo.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Cargo.toml b/Cargo.toml index c9cb6d5..b86db35 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -4,7 +4,7 @@ description = "Numeric traits for generic mathematics" documentation = "https://docs.rs/num-traits" homepage = "https://github.com/rust-num/num-traits" keywords = ["mathematics", "numerics"] -categories = [ "algorithms", "science" ] +categories = ["algorithms", "science", "no-std"] license = "MIT/Apache-2.0" repository = "https://github.com/rust-num/num-traits" name = "num-traits" From 5add4c580efde6d420e0588a8eee72dfc4f96c5b Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 May 2018 17:27:44 -0700 Subject: [PATCH 3/4] Enable all features for docs.rs --- Cargo.toml | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Cargo.toml b/Cargo.toml index b86db35..98d7ca9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -11,6 +11,9 @@ name = "num-traits" version = "0.2.2" readme = "README.md" +[package.metadata.docs.rs] +all-features = true + [dependencies] [features] From 7e055b131f61829decd64382d98732ebe016c080 Mon Sep 17 00:00:00 2001 From: Josh Stone Date: Tue, 8 May 2018 17:35:59 -0700 Subject: [PATCH 4/4] Document more impls that require std --- README.md | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 3aab842..2c16617 100644 --- a/README.md +++ b/README.md @@ -34,7 +34,9 @@ default-features = false ``` The `Float` and `Real` traits are only available when `std` is enabled. The -`FloatCore` trait is always available. +`FloatCore` trait is always available. `MulAdd` and `MulAddAssign` for `f32` +and `f64` also require `std`, as do implementations of signed and floating- +point exponents in `Pow`. Implementations for `i128` and `u128` are only available when `i128` is enabled.