Skip to content

Commit 500078e

Browse files
committed
Revert "Merge Exponential and Hyperbolic traits"
After discussions on IRC and #4819, we have decided to revert this change. This is due to the traits expressing different ideas and because hyperbolic functions are not trivially implementable from exponential functions for floating-point types.
1 parent d3f494f commit 500078e

File tree

6 files changed

+11
-5
lines changed

6 files changed

+11
-5
lines changed

src/libcore/core.rc

+1-1
Original file line numberDiff line numberDiff line change
@@ -105,7 +105,7 @@ pub use iter::{ExtendedMutableIter};
105105

106106
pub use num::{Num, NumCast};
107107
pub use num::{Orderable, Signed, Unsigned, Round};
108-
pub use num::{Algebraic, Trigonometric, Exponential};
108+
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
109109
pub use num::{Integer, Fractional, Real, RealExt};
110110
pub use num::{Bitwise, BitCount, Bounded};
111111
pub use num::{Primitive, Int, Float};

src/libcore/num/f32.rs

+2
Original file line numberDiff line numberDiff line change
@@ -425,7 +425,9 @@ impl Exponential for f32 {
425425

426426
#[inline(always)]
427427
fn log10(&self) -> f32 { log10(*self) }
428+
}
428429

430+
impl Hyperbolic for f32 {
429431
#[inline(always)]
430432
fn sinh(&self) -> f32 { sinh(*self) }
431433

src/libcore/num/f64.rs

+2
Original file line numberDiff line numberDiff line change
@@ -437,7 +437,9 @@ impl Exponential for f64 {
437437

438438
#[inline(always)]
439439
fn log10(&self) -> f64 { log10(*self) }
440+
}
440441

442+
impl Hyperbolic for f64 {
441443
#[inline(always)]
442444
fn sinh(&self) -> f64 { sinh(*self) }
443445

src/libcore/num/float.rs

+2
Original file line numberDiff line numberDiff line change
@@ -547,7 +547,9 @@ impl Exponential for float {
547547
fn log10(&self) -> float {
548548
(*self as f64).log10() as float
549549
}
550+
}
550551
552+
impl Hyperbolic for float {
551553
#[inline(always)]
552554
fn sinh(&self) -> float {
553555
(*self as f64).sinh() as float

src/libcore/num/num.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -131,9 +131,9 @@ pub trait Exponential {
131131
fn log(&self) -> Self;
132132
fn log2(&self) -> Self;
133133
fn log10(&self) -> Self;
134+
}
134135

135-
// The Hyperbolic Functions are trivially implemented in terms of `exp`, so it's simpler
136-
// to group them within this trait. In the future these would have default implementations.
136+
pub trait Hyperbolic: Exponential {
137137
fn sinh(&self) -> Self;
138138
fn cosh(&self) -> Self;
139139
fn tanh(&self) -> Self;
@@ -146,7 +146,7 @@ pub trait Real: Signed
146146
+ Fractional
147147
+ Algebraic
148148
+ Trigonometric
149-
+ Exponential {
149+
+ Hyperbolic {
150150
// Common Constants
151151
// FIXME (#5527): These should be associated constants
152152
fn pi() -> Self;

src/libcore/prelude.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ pub use iter::{CopyableIter, CopyableOrderedIter, CopyableNonstrictIter};
3939
pub use iter::{Times, ExtendedMutableIter};
4040
pub use num::{Num, NumCast};
4141
pub use num::{Orderable, Signed, Unsigned, Round};
42-
pub use num::{Algebraic, Trigonometric, Exponential};
42+
pub use num::{Algebraic, Trigonometric, Exponential, Hyperbolic};
4343
pub use num::{Integer, Fractional, Real, RealExt};
4444
pub use num::{Bitwise, BitCount, Bounded};
4545
pub use num::{Primitive, Int, Float};

0 commit comments

Comments
 (0)