Skip to content

Commit bf10a83

Browse files
committed
---
yaml --- r: 57963 b: refs/heads/incoming c: 17ca136 h: refs/heads/master i: 57961: 34b5623 57959: be73f7f v: v3
1 parent 932fc24 commit bf10a83

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

60 files changed

+664
-687
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ refs/heads/try: bf67eb2362b7d0f37012f2d6dac604c3bbacd2c6
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c
9-
refs/heads/incoming: ee26c7c433dbb8d41a2b65dbc89eb84acfc2d311
9+
refs/heads/incoming: 17ca13651a2bc6533413d80eb8941e5ddb20820e
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: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1467,8 +1467,8 @@ A complete list of the built-in language items follows:
14671467
: Elements can be subtracted.
14681468
`mul`
14691469
: Elements can be multiplied.
1470-
`div`
1471-
: Elements have a division operation.
1470+
`quot`
1471+
: Elements have a quotient operation.
14721472
`rem`
14731473
: Elements have a remainder operation.
14741474
`neg`
@@ -1857,7 +1857,7 @@ The default meaning of the operators on standard types is given here.
18571857
Calls the `mul` method on the `core::ops::Mul` trait.
18581858
`/`
18591859
: Quotient.
1860-
Calls the `div` method on the `core::ops::Div` trait.
1860+
Calls the `quot` method on the `core::ops::Quot` trait.
18611861
`%`
18621862
: Remainder.
18631863
Calls the `rem` method on the `core::ops::Rem` trait.

branches/incoming/mk/clean.mk

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ clean-misc:
4848
$(Q)rm -f $(RUSTLLVM_LIB_OBJS) $(RUSTLLVM_OBJS_OBJS) $(RUSTLLVM_DEF)
4949
$(Q)rm -Rf $(DOCS)
5050
$(Q)rm -Rf $(GENERATED)
51-
$(Q)rm -f tmp/*.log tmp/*.rc tmp/*.rs tmp/*.ok
51+
$(Q)rm -f tmp/*
5252
$(Q)rm -Rf rust-stage0-*.tar.bz2 $(PKG_NAME)-*.tar.gz dist
5353
$(Q)rm -Rf $(foreach ext, \
5454
html aux cp fn ky log pdf pg toc tp vr cps, \

branches/incoming/src/libcore/char.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
//! Utilities for manipulating the char type
1212
13+
#[cfg(notest)]
1314
use cmp::Ord;
1415
use option::{None, Option, Some};
1516
use str;

branches/incoming/src/libcore/core.rc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,7 @@ pub use ops::{Drop};
7878
#[cfg(stage0)]
7979
pub use ops::{Add, Sub, Mul, Div, Modulo, Neg, Not};
8080
#[cfg(not(stage0))]
81-
pub use ops::{Add, Sub, Mul, Div, Rem, Neg, Not};
81+
pub use ops::{Add, Sub, Mul, Quot, Rem, Neg, Not};
8282
pub use ops::{BitAnd, BitOr, BitXor};
8383
pub use ops::{Shl, Shr, Index};
8484

branches/incoming/src/libcore/iter.rs

Lines changed: 93 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,9 @@ much easier to implement.
4141
4242
*/
4343

44+
use cmp::Ord;
45+
use option::{Option, Some, None};
46+
4447
pub trait Times {
4548
fn times(&self, it: &fn() -> bool);
4649
}
@@ -104,6 +107,78 @@ pub fn all<T>(predicate: &fn(T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> bool {
104107
true
105108
}
106109

110+
/**
111+
* Return the first element where `predicate` returns `true`. Return `None` if no element is found.
112+
*
113+
* # Example:
114+
*
115+
* ~~~~
116+
* let xs = ~[1u, 2, 3, 4, 5, 6];
117+
* assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4);
118+
* ~~~~
119+
*/
120+
#[inline(always)]
121+
pub fn find<T>(predicate: &fn(&T) -> bool, iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
122+
for iter |x| {
123+
if predicate(&x) {
124+
return Some(x);
125+
}
126+
}
127+
None
128+
}
129+
130+
/**
131+
* Return the largest item yielded by an iterator. Return `None` if the iterator is empty.
132+
*
133+
* # Example:
134+
*
135+
* ~~~~
136+
* let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
137+
* assert_eq!(max(|f| xs.each(f)).unwrap(), &15);
138+
* ~~~~
139+
*/
140+
#[inline]
141+
pub fn max<T: Ord>(iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
142+
let mut result = None;
143+
for iter |x| {
144+
match result {
145+
Some(ref mut y) => {
146+
if x > *y {
147+
*y = x;
148+
}
149+
}
150+
None => result = Some(x)
151+
}
152+
}
153+
result
154+
}
155+
156+
/**
157+
* Return the smallest item yielded by an iterator. Return `None` if the iterator is empty.
158+
*
159+
* # Example:
160+
*
161+
* ~~~~
162+
* let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
163+
* assert_eq!(max(|f| xs.each(f)).unwrap(), &-5);
164+
* ~~~~
165+
*/
166+
#[inline]
167+
pub fn min<T: Ord>(iter: &fn(f: &fn(T) -> bool)) -> Option<T> {
168+
let mut result = None;
169+
for iter |x| {
170+
match result {
171+
Some(ref mut y) => {
172+
if x < *y {
173+
*y = x;
174+
}
175+
}
176+
None => result = Some(x)
177+
}
178+
}
179+
result
180+
}
181+
107182
#[cfg(test)]
108183
mod tests {
109184
use super::*;
@@ -128,4 +203,22 @@ mod tests {
128203
assert!(all(|x: uint| x < 6, |f| uint::range(1, 6, f)));
129204
assert!(!all(|x: uint| x < 5, |f| uint::range(1, 6, f)));
130205
}
206+
207+
#[test]
208+
fn test_find() {
209+
let xs = ~[1u, 2, 3, 4, 5, 6];
210+
assert_eq!(*find(|& &x: & &uint| x > 3, |f| xs.each(f)).unwrap(), 4);
211+
}
212+
213+
#[test]
214+
fn test_max() {
215+
let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
216+
assert_eq!(max(|f| xs.each(f)).unwrap(), &15);
217+
}
218+
219+
#[test]
220+
fn test_min() {
221+
let xs = ~[8, 2, 3, 1, -5, 9, 11, 15];
222+
assert_eq!(min(|f| xs.each(f)).unwrap(), &-5);
223+
}
131224
}

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,7 @@ pub fn sub(x: f32, y: f32) -> f32 { return x - y; }
123123
pub fn mul(x: f32, y: f32) -> f32 { return x * y; }
124124

125125
#[inline(always)]
126-
pub fn div(x: f32, y: f32) -> f32 { return x / y; }
126+
pub fn quot(x: f32, y: f32) -> f32 { return x / y; }
127127

128128
#[inline(always)]
129129
pub fn rem(x: f32, y: f32) -> f32 { return x % y; }
@@ -279,11 +279,16 @@ impl Mul<f32,f32> for f32 {
279279
fn mul(&self, other: &f32) -> f32 { *self * *other }
280280
}
281281

282-
#[cfg(notest)]
282+
#[cfg(stage0,notest)]
283283
impl Div<f32,f32> for f32 {
284284
#[inline(always)]
285285
fn div(&self, other: &f32) -> f32 { *self / *other }
286286
}
287+
#[cfg(not(stage0),notest)]
288+
impl Quot<f32,f32> for f32 {
289+
#[inline(always)]
290+
fn quot(&self, other: &f32) -> f32 { *self / *other }
291+
}
287292

288293
#[cfg(stage0,notest)]
289294
impl Modulo<f32,f32> for f32 {

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

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -149,7 +149,7 @@ pub fn sub(x: f64, y: f64) -> f64 { return x - y; }
149149
pub fn mul(x: f64, y: f64) -> f64 { return x * y; }
150150

151151
#[inline(always)]
152-
pub fn div(x: f64, y: f64) -> f64 { return x / y; }
152+
pub fn quot(x: f64, y: f64) -> f64 { return x / y; }
153153

154154
#[inline(always)]
155155
pub fn rem(x: f64, y: f64) -> f64 { return x % y; }
@@ -296,10 +296,15 @@ impl Sub<f64,f64> for f64 {
296296
impl Mul<f64,f64> for f64 {
297297
fn mul(&self, other: &f64) -> f64 { *self * *other }
298298
}
299-
#[cfg(notest)]
299+
#[cfg(stage0,notest)]
300300
impl Div<f64,f64> for f64 {
301301
fn div(&self, other: &f64) -> f64 { *self / *other }
302302
}
303+
#[cfg(not(stage0),notest)]
304+
impl Quot<f64,f64> for f64 {
305+
#[inline(always)]
306+
fn quot(&self, other: &f64) -> f64 { *self / *other }
307+
}
303308
#[cfg(stage0,notest)]
304309
impl Modulo<f64,f64> for f64 {
305310
fn modulo(&self, other: &f64) -> f64 { *self % *other }

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

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ use libc::c_int;
2525
use num::{Zero, One, strconv};
2626
use prelude::*;
2727

28-
pub use f64::{add, sub, mul, div, rem, lt, le, eq, ne, ge, gt};
28+
pub use f64::{add, sub, mul, quot, rem, lt, le, eq, ne, ge, gt};
2929
pub use f64::logarithm;
3030
pub use f64::{acos, asin, atan2, cbrt, ceil, copysign, cosh, floor};
3131
pub use f64::{erf, erfc, exp, expm1, exp2, abs_sub};
@@ -692,12 +692,16 @@ impl Mul<float,float> for float {
692692
fn mul(&self, other: &float) -> float { *self * *other }
693693
}
694694
695-
#[cfg(notest)]
695+
#[cfg(stage0,notest)]
696696
impl Div<float,float> for float {
697697
#[inline(always)]
698698
fn div(&self, other: &float) -> float { *self / *other }
699699
}
700-
700+
#[cfg(not(stage0),notest)]
701+
impl Quot<float,float> for float {
702+
#[inline(always)]
703+
fn quot(&self, other: &float) -> float { *self / *other }
704+
}
701705
#[cfg(stage0,notest)]
702706
impl Modulo<float,float> for float {
703707
#[inline(always)]

0 commit comments

Comments
 (0)