Skip to content

Commit 29b7b7d

Browse files
committed
Minor cleanups on ComplexFloat
1 parent cc104ab commit 29b7b7d

File tree

2 files changed

+13
-11
lines changed

2 files changed

+13
-11
lines changed

src/complex_float.rs

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// Keeps us from accidentally creating a recursive impl rather than a real one.
22
#![deny(unconditional_recursion)]
3-
#![cfg(any(feature = "std", feature = "libm"))]
43

54
use core::ops::Neg;
65

@@ -19,9 +18,13 @@ mod private {
1918
impl<T: Float + FloatConst> Seal for Complex<T> {}
2019
}
2120

22-
/// Generic trait for floating point complex numbers
23-
/// This trait defines methods which are common to complex floating point numbers and regular floating point numbers.
24-
/// This trait is sealed to prevent it from being implemented by anything other than floating point scalars and [Complex] floats.
21+
/// Generic trait for floating point complex numbers.
22+
///
23+
/// This trait defines methods which are common to complex floating point
24+
/// numbers and regular floating point numbers.
25+
///
26+
/// This trait is sealed to prevent it from being implemented by anything other
27+
/// than floating point scalars and [Complex] floats.
2528
pub trait ComplexFloat: Num + NumCast + Copy + Neg<Output = Self> + private::Seal {
2629
/// The type used to represent the real coefficients of this complex number.
2730
type Real: Float + FloatConst;
@@ -192,7 +195,7 @@ where
192195
}
193196

194197
fn powc(self, exp: Complex<Self::Real>) -> Complex<Self::Real> {
195-
Complex::new(self, Self::Real::zero()).powc(exp)
198+
Complex::new(self, T::zero()).powc(exp)
196199
}
197200

198201
fn conj(self) -> Self {

src/lib.rs

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,20 +30,19 @@ use core::str::FromStr;
3030
#[cfg(feature = "std")]
3131
use std::error::Error;
3232

33-
use num_traits::{FloatConst, Inv, MulAdd, Num, One, Pow, Signed, Zero};
33+
use num_traits::{Inv, MulAdd, Num, One, Pow, Signed, Zero};
3434

35-
#[cfg(any(feature = "std", feature = "libm"))]
36-
use num_traits::float::Float;
3735
use num_traits::float::FloatCore;
38-
3936
#[cfg(any(feature = "std", feature = "libm"))]
40-
mod complex_float;
37+
use num_traits::float::{Float, FloatConst};
4138

4239
mod cast;
4340
mod pow;
4441

4542
#[cfg(any(feature = "std", feature = "libm"))]
46-
pub use complex_float::ComplexFloat;
43+
mod complex_float;
44+
#[cfg(any(feature = "std", feature = "libm"))]
45+
pub use crate::complex_float::ComplexFloat;
4746

4847
#[cfg(feature = "rand")]
4948
mod crand;

0 commit comments

Comments
 (0)