Skip to content

Commit

Permalink
INCOMPLETE: Directly reference num sub-crates.
Browse files Browse the repository at this point in the history
Resolves #57.
  • Loading branch information
iliekturtles committed Mar 14, 2018
1 parent eb2ec08 commit 78c3e98
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 4 deletions.
4 changes: 2 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ coveralls = { repository = "iliekturtles/uom" }
maintenance = { status = "actively-developed" }

[dependencies]
num = "0.1"
num-traits = { version = "0.2", default-features = false }
serde = { version = "1.0", optional = true, default-features = false }
typenum = "1.9.0"

Expand Down Expand Up @@ -52,7 +52,7 @@ bigrational = []
f32 = []
f64 = []
si = []
std = []
std = ["num-traits/std"]
# The `use_serde` feature exists so that, in the future, other dependency features like num/serde
# can be added. However, num/serde is currently left out because it has not yet been updated to
# Serde 1.0. It is also necessary to name the feature something other than `serde` because of a
Expand Down
15 changes: 13 additions & 2 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -168,7 +168,7 @@ compile_error!("A least one underlying storage type must be enabled. See the fea
uom documentation for available underlying storage type options.");

#[doc(hidden)]
pub extern crate num;
pub extern crate num_traits;

#[doc(hidden)]
#[cfg(feature = "serde")]
Expand Down Expand Up @@ -210,6 +210,17 @@ pub mod lib {
}
}

// Conditionally import num sub-crate types based on feature selection.
#[doc(hidden)]
pub mod num {
#[cfg(not(feature = "std"))]
pub use num_traits::float::FloatCore as Float;
#[cfg(feature = "std")]
pub use num_traits::float::Float;

pub use num_traits::{Num, One, Saturating, Signed, Zero};
}

#[macro_use]
mod storage_types;

Expand Down Expand Up @@ -288,7 +299,7 @@ storage_types! {
impl ::ConversionFactor<V> for V {
#[inline(always)]
fn powi(self, e: i32) -> Self {
self.powi(e)
<V as ::num::Float>::powi(self, e)
}

#[inline(always)]
Expand Down
1 change: 1 addition & 0 deletions src/si/length.rs
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,7 @@ where
V: ::num::Float + ::Conversion<V>,
{
/// Calculates the length of the hypotenuse of a right-angle triangle given the legs.
#[cfg(feature = "std")]
#[inline(always)]
pub fn hypot(self, other: Self) -> Self {
Length {
Expand Down
3 changes: 3 additions & 0 deletions src/system.rs
Original file line number Diff line number Diff line change
Expand Up @@ -521,6 +521,7 @@ macro_rules! system {
/// // error[E0271]: type mismatch resolving ...
/// let r = Area::new::<square_meter>(8.0).cbrt();
/// ```
#[cfg(feature = "std")]
#[inline(always)]
pub fn cbrt(
self
Expand Down Expand Up @@ -595,6 +596,7 @@ macro_rules! system {
/// Fused multiply-add. Computes `(self * a) + b` with only one rounding error.
/// This produces a more accurate result with better performance than a separate
/// multiplication operation followed by an add.
#[cfg(feature = "std")]
#[inline(always)]
pub fn mul_add<Da, Ua, Ub>(
self,
Expand Down Expand Up @@ -682,6 +684,7 @@ macro_rules! system {
/// // error[E0271]: type mismatch resolving ...
/// let r = Length::new::<meter>(4.0).sqrt();
/// ```
#[cfg(feature = "std")]
#[inline(always)]
pub fn sqrt(
self
Expand Down

0 comments on commit 78c3e98

Please sign in to comment.