Skip to content
This repository was archived by the owner on Apr 28, 2025. It is now read-only.

Commit 9f0bc49

Browse files
committed
fix traits
1 parent 61e3809 commit 9f0bc49

File tree

2 files changed

+28
-44
lines changed

2 files changed

+28
-44
lines changed

build.rs

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -41,18 +41,18 @@ mod musl_reference_tests {
4141
"rem_pio2.rs",
4242
"rem_pio2_large.rs",
4343
"rem_pio2f.rs",
44-
"remquo.rs", // more than 1 result
45-
"remquof.rs", // more than 1 result
44+
"remquo.rs", // more than 1 result
45+
"remquof.rs", // more than 1 result
4646
"lgamma_r.rs", // more than 1 result
4747
"lgammaf_r.rs", // more than 1 result
48-
"frexp.rs", // more than 1 result
49-
"frexpf.rs", // more than 1 result
50-
"sincos.rs", // more than 1 result
51-
"sincosf.rs", // more than 1 result
52-
"modf.rs", // more than 1 result
53-
"modff.rs", // more than 1 result
54-
"jn.rs", // passed, but very slow
55-
"jnf.rs", // passed, but very slow
48+
"frexp.rs", // more than 1 result
49+
"frexpf.rs", // more than 1 result
50+
"sincos.rs", // more than 1 result
51+
"sincosf.rs", // more than 1 result
52+
"modf.rs", // more than 1 result
53+
"modff.rs", // more than 1 result
54+
"jn.rs", // passed, but very slow
55+
"jnf.rs", // passed, but very slow
5656
];
5757

5858
struct Function {

src/lib.rs

Lines changed: 18 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -119,13 +119,7 @@ pub trait F32Ext: private::Sealed + Sized {
119119

120120
fn atan2(self, other: Self) -> Self;
121121

122-
#[inline]
123-
fn sin_cos(self) -> (Self, Self)
124-
where
125-
Self: Copy,
126-
{
127-
(self.sin(), self.cos())
128-
}
122+
fn sin_cos(self) -> (Self, Self);
129123

130124
fn exp_m1(self) -> Self;
131125

@@ -289,6 +283,11 @@ impl F32Ext for f32 {
289283
atan2f(self, other)
290284
}
291285

286+
#[inline]
287+
fn sin_cos(self) -> (Self, Self) {
288+
sincosf(self)
289+
}
290+
292291
#[inline]
293292
fn exp_m1(self) -> Self {
294293
expm1f(self)
@@ -316,24 +315,17 @@ impl F32Ext for f32 {
316315

317316
#[inline]
318317
fn asinh(self) -> Self {
319-
if self == f32::NEG_INFINITY {
320-
f32::NEG_INFINITY
321-
} else {
322-
(self + ((self * self) + 1.0).sqrt()).ln()
323-
}
318+
asinhf(self)
324319
}
325320

326321
#[inline]
327322
fn acosh(self) -> Self {
328-
match self {
329-
x if x < 1.0 => f32::NAN,
330-
x => (x + ((x * x) - 1.0).sqrt()).ln(),
331-
}
323+
acoshf(self)
332324
}
333325

334326
#[inline]
335327
fn atanh(self) -> Self {
336-
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
328+
atanhf(self)
337329
}
338330
}
339331

@@ -401,13 +393,7 @@ pub trait F64Ext: private::Sealed + Sized {
401393

402394
fn atan2(self, other: Self) -> Self;
403395

404-
#[inline]
405-
fn sin_cos(self) -> (Self, Self)
406-
where
407-
Self: Copy,
408-
{
409-
(self.sin(), self.cos())
410-
}
396+
fn sin_cos(self) -> (Self, Self);
411397

412398
fn exp_m1(self) -> Self;
413399

@@ -571,6 +557,11 @@ impl F64Ext for f64 {
571557
atan2(self, other)
572558
}
573559

560+
#[inline]
561+
fn sin_cos(self) -> (Self, Self) {
562+
sincos(self)
563+
}
564+
574565
#[inline]
575566
fn exp_m1(self) -> Self {
576567
expm1(self)
@@ -598,24 +589,17 @@ impl F64Ext for f64 {
598589

599590
#[inline]
600591
fn asinh(self) -> Self {
601-
if self == f64::NEG_INFINITY {
602-
f64::NEG_INFINITY
603-
} else {
604-
(self + ((self * self) + 1.0).sqrt()).ln()
605-
}
592+
asinh(self)
606593
}
607594

608595
#[inline]
609596
fn acosh(self) -> Self {
610-
match self {
611-
x if x < 1.0 => f64::NAN,
612-
x => (x + ((x * x) - 1.0).sqrt()).ln(),
613-
}
597+
acosh(self)
614598
}
615599

616600
#[inline]
617601
fn atanh(self) -> Self {
618-
0.5 * ((2.0 * self) / (1.0 - self)).ln_1p()
602+
atanh(self)
619603
}
620604
}
621605

0 commit comments

Comments
 (0)