Skip to content

Commit c6beb3e

Browse files
committed
---
yaml --- r: 59123 b: refs/heads/incoming c: 8d4d2b0 h: refs/heads/master i: 59121: b96f3d7 59119: 6273bd0 v: v3
1 parent 05a641b commit c6beb3e

File tree

24 files changed

+333
-266
lines changed

24 files changed

+333
-266
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: c50a9d5b664478e533ba1d1d353213d70c8ad589
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: 1bf2f68bb255cc6833d4253c4f6d071af9e05648
9+
refs/heads/incoming: 8d4d2b00c551301348cc09583498c02fdfbd64d7
1010
refs/heads/dist-snap: 00dbbd01c2aee72982b3e0f9511ae1d4428c3ba9
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/incoming/doc/rust.md

Lines changed: 0 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -1425,8 +1425,6 @@ names are effectively reserved. Some significant attributes include:
14251425
* The `test` attribute, for marking functions as unit tests.
14261426
* The `allow`, `warn`, `forbid`, and `deny` attributes, for controlling lint checks. Lint checks supported
14271427
by the compiler can be found via `rustc -W help`.
1428-
* The `deriving` attribute, for automatically generating
1429-
implementations of certain traits.
14301428

14311429
Other attributes may be added or removed during development of the language.
14321430

@@ -1528,47 +1526,6 @@ A complete list of the built-in language items follows:
15281526
> **Note:** This list is likely to become out of date. We should auto-generate it
15291527
> from `librustc/middle/lang_items.rs`.
15301528
1531-
### Deriving
1532-
1533-
The `deriving` attribute allows certain traits to be automatically
1534-
implemented for data structures. For example, the following will
1535-
create an `impl` for the `Eq` and `Clone` traits for `Foo`, the type
1536-
parameter `T` will be given the `Eq` or `Clone` constraints for the
1537-
appropriate `impl`:
1538-
1539-
~~~
1540-
#[deriving(Eq, Clone)]
1541-
struct Foo<T> {
1542-
a: int,
1543-
b: T
1544-
}
1545-
~~~
1546-
1547-
The generated `impl` for `Eq` is equivalent to
1548-
1549-
~~~
1550-
# struct Foo<T> { a: int, b: T }
1551-
impl<T: Eq> Eq for Foo<T> {
1552-
fn eq(&self, other: &Foo<T>) -> bool {
1553-
self.a == other.a && self.b == other.b
1554-
}
1555-
1556-
fn ne(&self, other: &Foo<T>) -> bool {
1557-
self.a != other.a || self.b != other.b
1558-
}
1559-
}
1560-
~~~
1561-
1562-
Supported traits for `deriving` are:
1563-
1564-
* Comparison traits: `Eq`, `TotalEq`, `Ord`, `TotalOrd`.
1565-
* Serialization: `Encodable`, `Decodable`. These require `std`.
1566-
* `Clone`, to perform deep copies.
1567-
* `IterBytes`, to iterate over the bytes in a data type.
1568-
* `Rand`, to create a random instance of a data type.
1569-
* `ToStr`, to convert to a string. For a type with this instance,
1570-
`obj.to_str()` has the same output as `fmt!("%?", obj)`.
1571-
15721529
# Statements and expressions
15731530

15741531
Rust is _primarily_ an expression language. This means that most forms of

branches/incoming/doc/tutorial.md

Lines changed: 0 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -2290,27 +2290,6 @@ let nonsense = mycircle.radius() * mycircle.area();
22902290

22912291
> ***Note:*** Trait inheritance does not actually work with objects yet
22922292
2293-
## Deriving implementations for traits
2294-
2295-
A small number of traits in `core` and `std` can have implementations
2296-
that can be automatically derived. These instances are specified by
2297-
placing the `deriving` attribute on a data type declaration. For
2298-
example, the following will mean that `Circle` has an implementation
2299-
for `Eq` and can be used with the equality operators, and that a value
2300-
of type `ABC` can be randomly generated and converted to a string:
2301-
2302-
~~~
2303-
#[deriving(Eq)]
2304-
struct Circle { radius: float }
2305-
2306-
#[deriving(Rand, ToStr)]
2307-
enum ABC { A, B, C }
2308-
~~~
2309-
2310-
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2311-
`TotalOrd`, `Encodable` `Decodable`, `Clone`, `IterBytes`, `Rand` and
2312-
`ToStr`.
2313-
23142293
# Modules and crates
23152294

23162295
The Rust namespace is arranged in a hierarchy of modules. Each source

branches/incoming/src/driver/driver.rs

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,9 @@
88
// option. This file may not be copied, modified, or distributed
99
// except according to those terms.
1010

11+
#[no_core];
12+
extern mod core(vers = "0.7-pre");
13+
1114
#[cfg(rustpkg)]
1215
extern mod this(name = "rustpkg", vers = "0.7-pre");
1316

branches/incoming/src/libcore/num/f32.rs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -450,6 +450,58 @@ impl Hyperbolic for f32 {
450450

451451
#[inline(always)]
452452
fn tanh(&self) -> f32 { tanh(*self) }
453+
454+
///
455+
/// Inverse hyperbolic sine
456+
///
457+
/// # Returns
458+
///
459+
/// - on success, the inverse hyperbolic sine of `self` will be returned
460+
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
461+
/// - `NaN` if `self` is `NaN`
462+
///
463+
#[inline(always)]
464+
fn asinh(&self) -> f32 {
465+
match *self {
466+
infinity => infinity,
467+
neg_infinity => neg_infinity,
468+
x => (x + ((x * x) + 1.0).sqrt()).ln(),
469+
}
470+
}
471+
472+
///
473+
/// Inverse hyperbolic cosine
474+
///
475+
/// # Returns
476+
///
477+
/// - on success, the inverse hyperbolic cosine of `self` will be returned
478+
/// - `infinity` if `self` is `infinity`
479+
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
480+
///
481+
#[inline(always)]
482+
fn acosh(&self) -> f32 {
483+
match *self {
484+
x if x < 1.0 => Float::NaN(),
485+
x => (x + ((x * x) - 1.0).sqrt()).ln(),
486+
}
487+
}
488+
489+
///
490+
/// Inverse hyperbolic tangent
491+
///
492+
/// # Returns
493+
///
494+
/// - on success, the inverse hyperbolic tangent of `self` will be returned
495+
/// - `self` if `self` is `0.0` or `-0.0`
496+
/// - `infinity` if `self` is `1.0`
497+
/// - `neg_infinity` if `self` is `-1.0`
498+
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
499+
/// (including `infinity` and `neg_infinity`)
500+
///
501+
#[inline(always)]
502+
fn atanh(&self) -> f32 {
503+
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
504+
}
453505
}
454506

455507
impl Real for f32 {
@@ -972,6 +1024,43 @@ mod tests {
9721024
assert_approx_eq!((-1.7f32).fract(), -0.7f32);
9731025
}
9741026

1027+
#[test]
1028+
fn test_asinh() {
1029+
assert_eq!(0.0f32.asinh(), 0.0f32);
1030+
assert_eq!((-0.0f32).asinh(), -0.0f32);
1031+
assert_eq!(Float::infinity::<f32>().asinh(), Float::infinity::<f32>());
1032+
assert_eq!(Float::neg_infinity::<f32>().asinh(), Float::neg_infinity::<f32>());
1033+
assert!(Float::NaN::<f32>().asinh().is_NaN());
1034+
assert_approx_eq!(2.0f32.asinh(), 1.443635475178810342493276740273105f32);
1035+
assert_approx_eq!((-2.0f32).asinh(), -1.443635475178810342493276740273105f32);
1036+
}
1037+
1038+
#[test]
1039+
fn test_acosh() {
1040+
assert_eq!(1.0f32.acosh(), 0.0f32);
1041+
assert!(0.999f32.acosh().is_NaN());
1042+
assert_eq!(Float::infinity::<f32>().acosh(), Float::infinity::<f32>());
1043+
assert!(Float::neg_infinity::<f32>().acosh().is_NaN());
1044+
assert!(Float::NaN::<f32>().acosh().is_NaN());
1045+
assert_approx_eq!(2.0f32.acosh(), 1.31695789692481670862504634730796844f32);
1046+
assert_approx_eq!(3.0f32.acosh(), 1.76274717403908605046521864995958461f32);
1047+
}
1048+
1049+
#[test]
1050+
fn test_atanh() {
1051+
assert_eq!(0.0f32.atanh(), 0.0f32);
1052+
assert_eq!((-0.0f32).atanh(), -0.0f32);
1053+
assert_eq!(1.0f32.atanh(), Float::infinity::<f32>());
1054+
assert_eq!((-1.0f32).atanh(), Float::neg_infinity::<f32>());
1055+
assert!(2f64.atanh().atanh().is_NaN());
1056+
assert!((-2f64).atanh().atanh().is_NaN());
1057+
assert!(Float::infinity::<f64>().atanh().is_NaN());
1058+
assert!(Float::neg_infinity::<f64>().atanh().is_NaN());
1059+
assert!(Float::NaN::<f32>().atanh().is_NaN());
1060+
assert_approx_eq!(0.5f32.atanh(), 0.54930614433405484569762261846126285f32);
1061+
assert_approx_eq!((-0.5f32).atanh(), -0.54930614433405484569762261846126285f32);
1062+
}
1063+
9751064
#[test]
9761065
fn test_real_consts() {
9771066
assert_approx_eq!(Real::two_pi::<f32>(), 2f32 * Real::pi::<f32>());

branches/incoming/src/libcore/num/f64.rs

Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -463,6 +463,58 @@ impl Hyperbolic for f64 {
463463

464464
#[inline(always)]
465465
fn tanh(&self) -> f64 { tanh(*self) }
466+
467+
///
468+
/// Inverse hyperbolic sine
469+
///
470+
/// # Returns
471+
///
472+
/// - on success, the inverse hyperbolic sine of `self` will be returned
473+
/// - `self` if `self` is `0.0`, `-0.0`, `infinity`, or `neg_infinity`
474+
/// - `NaN` if `self` is `NaN`
475+
///
476+
#[inline(always)]
477+
fn asinh(&self) -> f64 {
478+
match *self {
479+
infinity => infinity,
480+
neg_infinity => neg_infinity,
481+
x => (x + ((x * x) + 1.0).sqrt()).ln(),
482+
}
483+
}
484+
485+
///
486+
/// Inverse hyperbolic cosine
487+
///
488+
/// # Returns
489+
///
490+
/// - on success, the inverse hyperbolic cosine of `self` will be returned
491+
/// - `infinity` if `self` is `infinity`
492+
/// - `NaN` if `self` is `NaN` or `self < 1.0` (including `neg_infinity`)
493+
///
494+
#[inline(always)]
495+
fn acosh(&self) -> f64 {
496+
match *self {
497+
x if x < 1.0 => Float::NaN(),
498+
x => (x + ((x * x) - 1.0).sqrt()).ln(),
499+
}
500+
}
501+
502+
///
503+
/// Inverse hyperbolic tangent
504+
///
505+
/// # Returns
506+
///
507+
/// - on success, the inverse hyperbolic tangent of `self` will be returned
508+
/// - `self` if `self` is `0.0` or `-0.0`
509+
/// - `infinity` if `self` is `1.0`
510+
/// - `neg_infinity` if `self` is `-1.0`
511+
/// - `NaN` if the `self` is `NaN` or outside the domain of `-1.0 <= self <= 1.0`
512+
/// (including `infinity` and `neg_infinity`)
513+
///
514+
#[inline(always)]
515+
fn atanh(&self) -> f64 {
516+
0.5 * ((2.0 * *self) / (1.0 - *self)).ln_1p()
517+
}
466518
}
467519

468520
impl Real for f64 {
@@ -1019,6 +1071,43 @@ mod tests {
10191071
assert_approx_eq!((-1.7f64).fract(), -0.7f64);
10201072
}
10211073

1074+
#[test]
1075+
fn test_asinh() {
1076+
assert_eq!(0.0f64.asinh(), 0.0f64);
1077+
assert_eq!((-0.0f64).asinh(), -0.0f64);
1078+
assert_eq!(Float::infinity::<f64>().asinh(), Float::infinity::<f64>());
1079+
assert_eq!(Float::neg_infinity::<f64>().asinh(), Float::neg_infinity::<f64>());
1080+
assert!(Float::NaN::<f64>().asinh().is_NaN());
1081+
assert_approx_eq!(2.0f64.asinh(), 1.443635475178810342493276740273105f64);
1082+
assert_approx_eq!((-2.0f64).asinh(), -1.443635475178810342493276740273105f64);
1083+
}
1084+
1085+
#[test]
1086+
fn test_acosh() {
1087+
assert_eq!(1.0f64.acosh(), 0.0f64);
1088+
assert!(0.999f64.acosh().is_NaN());
1089+
assert_eq!(Float::infinity::<f64>().acosh(), Float::infinity::<f64>());
1090+
assert!(Float::neg_infinity::<f64>().acosh().is_NaN());
1091+
assert!(Float::NaN::<f64>().acosh().is_NaN());
1092+
assert_approx_eq!(2.0f64.acosh(), 1.31695789692481670862504634730796844f64);
1093+
assert_approx_eq!(3.0f64.acosh(), 1.76274717403908605046521864995958461f64);
1094+
}
1095+
1096+
#[test]
1097+
fn test_atanh() {
1098+
assert_eq!(0.0f64.atanh(), 0.0f64);
1099+
assert_eq!((-0.0f64).atanh(), -0.0f64);
1100+
assert_eq!(1.0f64.atanh(), Float::infinity::<f64>());
1101+
assert_eq!((-1.0f64).atanh(), Float::neg_infinity::<f64>());
1102+
assert!(2f64.atanh().atanh().is_NaN());
1103+
assert!((-2f64).atanh().atanh().is_NaN());
1104+
assert!(Float::infinity::<f64>().atanh().is_NaN());
1105+
assert!(Float::neg_infinity::<f64>().atanh().is_NaN());
1106+
assert!(Float::NaN::<f64>().atanh().is_NaN());
1107+
assert_approx_eq!(0.5f64.atanh(), 0.54930614433405484569762261846126285f64);
1108+
assert_approx_eq!((-0.5f64).atanh(), -0.54930614433405484569762261846126285f64);
1109+
}
1110+
10221111
#[test]
10231112
fn test_real_consts() {
10241113
assert_approx_eq!(Real::two_pi::<f64>(), 2.0 * Real::pi::<f64>());

0 commit comments

Comments
 (0)