Skip to content

Commit 2524636

Browse files
bogglemarijnh
authored andcommitted
std: declared fns in math to be pure; requires calling libc via unsafe
1 parent 68839c3 commit 2524636

File tree

1 file changed

+14
-14
lines changed

1 file changed

+14
-14
lines changed

src/lib/math.rs

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -22,49 +22,49 @@ Function: sqrt
2222
2323
Returns the square root
2424
*/
25-
fn sqrt(x: float) -> float { libc::sqrt(x) }
25+
pure fn sqrt(x: float) -> float { unsafe { libc::sqrt(x) } }
2626

2727
/*
2828
Function: sin
2929
3030
Returns the sine of an angle
3131
*/
32-
fn sin(x: float) -> float { libc::sin(x) }
32+
pure fn sin(x: float) -> float { unsafe { libc::sin(x) } }
3333

3434
/*
3535
Function: cos
3636
3737
Returns the cosine of an angle
3838
*/
39-
fn cos(x: float) -> float { libc::cos(x) }
39+
pure fn cos(x: float) -> float { unsafe { libc::cos(x) } }
4040

4141
/*
4242
Function: tan
4343
4444
Returns the tangent of an angle
4545
*/
46-
fn tan(x: float) -> float { libc::tan(x) }
46+
pure fn tan(x: float) -> float { unsafe { libc::tan(x) } }
4747

4848
/*
4949
Function: asin
5050
5151
Returns the arcsine of an angle
5252
*/
53-
fn asin(x: float) -> float { libc::asin(x) }
53+
pure fn asin(x: float) -> float { unsafe { libc::asin(x) } }
5454

5555
/*
5656
Function: acos
5757
5858
Returns the arccosine of an angle
5959
*/
60-
fn acos(x: float) -> float { libc::acos(x) }
60+
pure fn acos(x: float) -> float { unsafe { libc::acos(x) } }
6161

6262
/*
6363
Function: atan
6464
6565
Returns the arctangent of an angle
6666
*/
67-
fn atan(x: float) -> float { libc::atan(x) }
67+
pure fn atan(x: float) -> float { unsafe { libc::atan(x) } }
6868

6969
/*
7070
Const: pi
@@ -78,14 +78,14 @@ Function: min
7878
7979
Returns the minimum of two values
8080
*/
81-
fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
81+
pure fn min<copy T>(x: T, y: T) -> T { x < y ? x : y }
8282

8383
/*
8484
Function: max
8585
8686
Returns the maximum of two values
8787
*/
88-
fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
88+
pure fn max<copy T>(x: T, y: T) -> T { x < y ? y : x }
8989

9090
/*
9191
Const: e
@@ -99,27 +99,27 @@ Function: ln
9999
100100
Returns the natural logaritm
101101
*/
102-
fn ln(n: float) -> float { libc::ln(n) }
102+
pure fn ln(n: float) -> float { unsafe { libc::ln(n) } }
103103

104104
/*
105105
Function: log2
106106
107107
Returns the logarithm to base 2
108108
*/
109-
fn log2(n: float) -> float { libc::log2(n) }
109+
pure fn log2(n: float) -> float { unsafe { libc::log2(n) } }
110110

111111
/*
112112
Function: log2
113113
114114
Returns the logarithm to base 10
115115
*/
116-
fn log10(n: float) -> float { libc::log10(n) }
116+
pure fn log10(n: float) -> float { unsafe { libc::log10(n) } }
117117

118118

119119
/*
120120
Function: log1p
121121
122-
Returns the natural logarithm of `1+n` accurately,
122+
Returns the natural logarithm of `1+n` accurately,
123123
even for very small values of `n`
124124
*/
125-
fn ln1p(n: float) -> float { libc::log1p(n) }
125+
pure fn ln1p(n: float) -> float { unsafe { libc::log1p(n) } }

0 commit comments

Comments
 (0)