Skip to content

Commit 99f7f76

Browse files
committed
---
yaml --- r: 64885 b: refs/heads/snap-stage3 c: 6534b4d h: refs/heads/master i: 64883: b353f46 v: v3
1 parent 9a520c6 commit 99f7f76

File tree

4 files changed

+30
-31
lines changed

4 files changed

+30
-31
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 9a2d183d6ae83a0119f5cce1f95e3770ddf5d689
4+
refs/heads/snap-stage3: 6534b4d4ce87940954b017bd27dc4e5fa7e59703
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libextra/unicode.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ pub mod icu {
1717
pub type UChar32 = char;
1818

1919
pub static TRUE : u8 = 1u8;
20-
pub static FALSE : u8 = 1u8;
20+
pub static FALSE : u8 = 0u8;
2121

2222
pub static UCHAR_ALPHABETIC : UProperty = 0;
2323
pub static UCHAR_BINARY_START : UProperty = 0; // = UCHAR_ALPHABETIC

branches/snap-stage3/src/libstd/num/num.rs

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

11-
//! An interface for numeric types
11+
//! Numeric traits and functions for generic mathematics.
12+
//!
13+
//! These are implemented for the primitive numeric types in `std::{u8, u16,
14+
//! u32, u64, uint, i8, i16, i32, i64, int, f32, f64, float}`.
1215
1316
#[allow(missing_doc)];
1417

@@ -19,9 +22,7 @@ use option::Option;
1922

2023
pub mod strconv;
2124

22-
///
2325
/// The base trait for numeric types
24-
///
2526
pub trait Num: Eq + Zero + One
2627
+ Neg<Self>
2728
+ Add<Self,Self>
@@ -45,18 +46,23 @@ pub trait Orderable: Ord {
4546
fn clamp(&self, mn: &Self, mx: &Self) -> Self;
4647
}
4748

48-
#[inline(always)] pub fn min<T: Orderable>(a: T, b: T) -> T { a.min(&b) }
49-
#[inline(always)] pub fn max<T: Orderable>(a: T, b: T) -> T { a.max(&b) }
49+
#[inline(always)] pub fn min<T: Orderable>(x: T, y: T) -> T { x.min(&y) }
50+
#[inline(always)] pub fn max<T: Orderable>(x: T, y: T) -> T { x.max(&y) }
51+
#[inline(always)] pub fn clamp<T: Orderable>(value: T, mn: T, mx: T) -> T { value.clamp(&mn, &mx) }
5052

5153
pub trait Zero {
5254
fn zero() -> Self; // FIXME (#5527): This should be an associated constant
5355
fn is_zero(&self) -> bool;
5456
}
5557

58+
#[inline(always)] pub fn zero<T: Zero>() -> T { Zero::zero() }
59+
5660
pub trait One {
5761
fn one() -> Self; // FIXME (#5527): This should be an associated constant
5862
}
5963

64+
#[inline(always)] pub fn one<T: One>() -> T { One::one() }
65+
6066
pub trait Signed: Num
6167
+ Neg<Self> {
6268
fn abs(&self) -> Self;
@@ -68,6 +74,7 @@ pub trait Signed: Num
6874
}
6975

7076
#[inline(always)] pub fn abs<T: Signed>(value: T) -> T { value.abs() }
77+
#[inline(always)] pub fn abs_sub<T: Signed>(x: T, y: T) -> T { x.abs_sub(&y) }
7178
#[inline(always)] pub fn signum<T: Signed>(value: T) -> T { value.signum() }
7279

7380
pub trait Unsigned: Num {}
@@ -90,6 +97,9 @@ pub trait Integer: Num
9097
fn is_odd(&self) -> bool;
9198
}
9299

100+
#[inline(always)] pub fn gcd<T: Integer>(x: T, y: T) -> T { x.gcd(&y) }
101+
#[inline(always)] pub fn lcm<T: Integer>(x: T, y: T) -> T { x.lcm(&y) }
102+
93103
pub trait Round {
94104
fn floor(&self) -> Self;
95105
fn ceil(&self) -> Self;
@@ -113,15 +123,21 @@ pub trait Algebraic {
113123
fn hypot(&self, other: &Self) -> Self;
114124
}
115125

126+
#[inline(always)] pub fn pow<T: Algebraic>(value: T, n: T) -> T { value.pow(&n) }
116127
#[inline(always)] pub fn sqrt<T: Algebraic>(value: T) -> T { value.sqrt() }
128+
#[inline(always)] pub fn rsqrt<T: Algebraic>(value: T) -> T { value.rsqrt() }
129+
#[inline(always)] pub fn cbrt<T: Algebraic>(value: T) -> T { value.cbrt() }
130+
#[inline(always)] pub fn hypot<T: Algebraic>(x: T, y: T) -> T { x.hypot(&y) }
117131

118132
pub trait Trigonometric {
119133
fn sin(&self) -> Self;
120134
fn cos(&self) -> Self;
121135
fn tan(&self) -> Self;
136+
122137
fn asin(&self) -> Self;
123138
fn acos(&self) -> Self;
124139
fn atan(&self) -> Self;
140+
125141
fn atan2(&self, other: &Self) -> Self;
126142
fn sin_cos(&self) -> (Self, Self);
127143
}
@@ -135,10 +151,12 @@ pub trait Trigonometric {
135151
#[inline(always)] pub fn atan<T: Trigonometric>(value: T) -> T { value.atan() }
136152

137153
#[inline(always)] pub fn atan2<T: Trigonometric>(x: T, y: T) -> T { x.atan2(&y) }
154+
#[inline(always)] pub fn sin_cos<T: Trigonometric>(value: T) -> (T, T) { value.sin_cos() }
138155

139156
pub trait Exponential {
140157
fn exp(&self) -> Self;
141158
fn exp2(&self) -> Self;
159+
142160
fn ln(&self) -> Self;
143161
fn log(&self, base: &Self) -> Self;
144162
fn log2(&self) -> Self;
@@ -157,6 +175,7 @@ pub trait Hyperbolic: Exponential {
157175
fn sinh(&self) -> Self;
158176
fn cosh(&self) -> Self;
159177
fn tanh(&self) -> Self;
178+
160179
fn asinh(&self) -> Self;
161180
fn acosh(&self) -> Self;
162181
fn atanh(&self) -> Self;
@@ -170,9 +189,7 @@ pub trait Hyperbolic: Exponential {
170189
#[inline(always)] pub fn acosh<T: Hyperbolic>(value: T) -> T { value.acosh() }
171190
#[inline(always)] pub fn atanh<T: Hyperbolic>(value: T) -> T { value.atanh() }
172191

173-
///
174192
/// Defines constants and methods common to real numbers
175-
///
176193
pub trait Real: Signed
177194
+ Fractional
178195
+ Algebraic
@@ -203,9 +220,7 @@ pub trait Real: Signed
203220
fn to_radians(&self) -> Self;
204221
}
205222

206-
///
207223
/// Methods that are harder to implement and not commonly used.
208-
///
209224
pub trait RealExt: Real {
210225
// FIXME (#5527): usages of `int` should be replaced with an associated
211226
// integer type once these are implemented
@@ -223,9 +238,7 @@ pub trait RealExt: Real {
223238
fn yn(&self, n: int) -> Self;
224239
}
225240

226-
///
227241
/// Collects the bitwise operators under one trait.
228-
///
229242
pub trait Bitwise: Not<Self>
230243
+ BitAnd<Self,Self>
231244
+ BitOr<Self,Self>
@@ -245,11 +258,9 @@ pub trait Bounded {
245258
fn max_value() -> Self;
246259
}
247260

248-
///
249261
/// Specifies the available operations common to all of Rust's core numeric primitives.
250262
/// These may not always make sense from a purely mathematical point of view, but
251263
/// may be useful for systems programming.
252-
///
253264
pub trait Primitive: Num
254265
+ NumCast
255266
+ Bounded
@@ -264,17 +275,13 @@ pub trait Primitive: Num
264275
fn bytes() -> uint;
265276
}
266277

267-
///
268278
/// A collection of traits relevant to primitive signed and unsigned integers
269-
///
270279
pub trait Int: Integer
271280
+ Primitive
272281
+ Bitwise
273282
+ BitCount {}
274283

275-
///
276284
/// Used for representing the classification of floating point numbers
277-
///
278285
#[deriving(Eq)]
279286
pub enum FPCategory {
280287
/// "Not a Number", often obtained by dividing by zero
@@ -289,9 +296,7 @@ pub enum FPCategory {
289296
FPNormal,
290297
}
291298

292-
///
293299
/// Primitive floating point numbers
294-
///
295300
pub trait Float: Real
296301
+ Signed
297302
+ Primitive
@@ -325,7 +330,10 @@ pub trait Float: Real
325330
fn next_after(&self, other: Self) -> Self;
326331
}
327332

328-
///
333+
#[inline(always)] pub fn exp_m1<T: Float>(value: T) -> T { value.exp_m1() }
334+
#[inline(always)] pub fn ln_1p<T: Float>(value: T) -> T { value.ln_1p() }
335+
#[inline(always)] pub fn mul_add<T: Float>(a: T, b: T, c: T) -> T { a.mul_add(b, c) }
336+
329337
/// Cast from one machine scalar to another
330338
///
331339
/// # Example
@@ -340,9 +348,7 @@ pub fn cast<T:NumCast,U:NumCast>(n: T) -> U {
340348
NumCast::from(n)
341349
}
342350

343-
///
344351
/// An interface for casting between machine scalars
345-
///
346352
pub trait NumCast {
347353
fn from<T:NumCast>(n: T) -> Self;
348354

@@ -414,7 +420,6 @@ pub trait FromStrRadix {
414420
pub fn from_str_radix(str: &str, radix: uint) -> Option<Self>;
415421
}
416422

417-
///
418423
/// Calculates a power to a given radix, optimized for uint `pow` and `radix`.
419424
///
420425
/// Returns `radix^pow` as `T`.

branches/snap-stage3/src/libsyntax/parse/token.rs

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -474,8 +474,6 @@ fn mk_fresh_ident_interner() -> @ident_interner {
474474
"while", // 64
475475

476476
"be", // 65
477-
"in", // 66
478-
"foreach", // 67
479477
];
480478

481479
@ident_interner {
@@ -572,10 +570,8 @@ pub mod keywords {
572570
False,
573571
Fn,
574572
For,
575-
ForEach,
576573
If,
577574
Impl,
578-
In,
579575
Let,
580576
__Log,
581577
Loop,
@@ -616,10 +612,8 @@ pub mod keywords {
616612
False => ident { name: 40, ctxt: 0 },
617613
Fn => ident { name: 41, ctxt: 0 },
618614
For => ident { name: 42, ctxt: 0 },
619-
ForEach => ident { name: 67, ctxt: 0 },
620615
If => ident { name: 43, ctxt: 0 },
621616
Impl => ident { name: 44, ctxt: 0 },
622-
In => ident { name: 66, ctxt: 0 },
623617
Let => ident { name: 45, ctxt: 0 },
624618
__Log => ident { name: 46, ctxt: 0 },
625619
Loop => ident { name: 47, ctxt: 0 },

0 commit comments

Comments
 (0)