Skip to content

Commit 2e3c84e

Browse files
committed
---
yaml --- r: 139759 b: refs/heads/try2 c: c2b1534 h: refs/heads/master i: 139757: 33c327f 139755: 7164b9f 139751: 73ea86c 139743: a277ae6 v: v3
1 parent cb2cd5b commit 2e3c84e

32 files changed

+1219
-553
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ refs/heads/snap-stage3: 78a7676898d9f80ab540c6df5d4c9ce35bb50463
55
refs/heads/try: 519addf6277dbafccbb4159db4b710c37eaa2ec5
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
8-
refs/heads/try2: 715810290f89dd95c4787ca0ee9019ee6e93477e
8+
refs/heads/try2: c2b15345c7aa150212c4121de94e693b3117d618
99
refs/heads/dist-snap: ba4081a5a8573875fed17545846f6f6902c8ba8d
1010
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1111
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/try2/src/libcore/core.rc

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub use vec::{OwnedVector, OwnedCopyableVector};
9999
pub use iter::{BaseIter, ExtendedIter, EqIter, CopyableIter};
100100
pub use iter::{CopyableOrderedIter, CopyableNonstrictIter, Times};
101101

102-
pub use num::{Num, NumCast};
102+
pub use num::NumCast;
103103
pub use ptr::Ptr;
104104
pub use to_str::ToStr;
105105
pub use clone::Clone;
@@ -176,7 +176,6 @@ pub mod from_str;
176176
#[path = "num/num.rs"]
177177
pub mod num;
178178
pub mod iter;
179-
pub mod iterator;
180179
pub mod to_str;
181180
pub mod to_bytes;
182181
pub mod clone;

branches/try2/src/libcore/iterator.rs

Lines changed: 0 additions & 101 deletions
This file was deleted.

branches/try2/src/libcore/libc.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -863,8 +863,6 @@ pub mod consts {
863863
pub static F_TEST : int = 3;
864864
pub static F_TLOCK : int = 2;
865865
pub static F_ULOCK : int = 0;
866-
pub static SIGKILL : int = 9;
867-
pub static SIGTERM : int = 15;
868866
}
869867
pub mod posix01 {
870868
}
@@ -932,8 +930,6 @@ pub mod consts {
932930
pub static F_TEST : int = 3;
933931
pub static F_TLOCK : int = 2;
934932
pub static F_ULOCK : int = 0;
935-
pub static SIGKILL : int = 9;
936-
pub static SIGTERM : int = 15;
937933
}
938934
pub mod posix01 {
939935
}
@@ -1002,8 +998,6 @@ pub mod consts {
1002998
pub static F_TEST : int = 3;
1003999
pub static F_TLOCK : int = 2;
10041000
pub static F_ULOCK : int = 0;
1005-
pub static SIGKILL : int = 9;
1006-
pub static SIGTERM : int = 15;
10071001
}
10081002
pub mod posix01 {
10091003
}
@@ -1488,17 +1482,6 @@ pub mod funcs {
14881482
-> ssize_t;
14891483
}
14901484
}
1491-
1492-
#[nolink]
1493-
#[abi = "cdecl"]
1494-
pub mod signal {
1495-
use libc::types::os::arch::c95::{c_int};
1496-
use libc::types::os::arch::posix88::{pid_t};
1497-
1498-
pub extern {
1499-
unsafe fn kill(pid: pid_t, sig: c_int) -> c_int;
1500-
}
1501-
}
15021485
}
15031486

15041487
#[cfg(target_os = "linux")]
@@ -1640,7 +1623,6 @@ pub mod funcs {
16401623
pub mod extra {
16411624

16421625
pub mod kernel32 {
1643-
use libc::types::os::arch::c95::{c_uint};
16441626
use libc::types::os::arch::extra::{BOOL, DWORD, HMODULE};
16451627
use libc::types::os::arch::extra::{LPCWSTR, LPWSTR, LPTCH};
16461628
use libc::types::os::arch::extra::{LPSECURITY_ATTRIBUTES};
@@ -1681,7 +1663,6 @@ pub mod funcs {
16811663
findFileData: HANDLE)
16821664
-> BOOL;
16831665
unsafe fn FindClose(findFile: HANDLE) -> BOOL;
1684-
unsafe fn TerminateProcess(hProcess: HANDLE, uExitCode: c_uint) -> BOOL;
16851666
}
16861667
}
16871668

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use cmath;
1414
use libc::{c_float, c_int};
15+
use num::NumCast;
1516
use num::strconv;
1617
use num;
1718
use option::Option;
@@ -286,6 +287,30 @@ impl num::One for f32 {
286287
fn one() -> f32 { 1.0 }
287288
}
288289

290+
impl NumCast for f32 {
291+
/**
292+
* Cast `n` to an `f32`
293+
*/
294+
#[inline(always)]
295+
fn from<N:NumCast>(n: N) -> f32 { n.to_f32() }
296+
297+
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
298+
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
299+
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
300+
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
301+
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
302+
303+
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
304+
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
305+
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
306+
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
307+
#[inline(always)] fn to_int(&self) -> int { *self as int }
308+
309+
#[inline(always)] fn to_f32(&self) -> f32 { *self }
310+
#[inline(always)] fn to_f64(&self) -> f64 { *self as f64 }
311+
#[inline(always)] fn to_float(&self) -> float { *self as float }
312+
}
313+
289314
#[cfg(notest)]
290315
impl ops::Add<f32,f32> for f32 {
291316
fn add(&self, other: &f32) -> f32 { *self + *other }
@@ -555,6 +580,63 @@ impl num::FromStrRadix for f32 {
555580
}
556581
}
557582

583+
#[test]
584+
pub fn test_num() {
585+
let ten: f32 = num::cast(10);
586+
let two: f32 = num::cast(2);
587+
588+
assert!((ten.add(&two) == num::cast(12)));
589+
assert!((ten.sub(&two) == num::cast(8)));
590+
assert!((ten.mul(&two) == num::cast(20)));
591+
assert!((ten.div(&two) == num::cast(5)));
592+
assert!((ten.modulo(&two) == num::cast(0)));
593+
}
594+
595+
#[test]
596+
fn test_numcast() {
597+
assert!((20u == 20f32.to_uint()));
598+
assert!((20u8 == 20f32.to_u8()));
599+
assert!((20u16 == 20f32.to_u16()));
600+
assert!((20u32 == 20f32.to_u32()));
601+
assert!((20u64 == 20f32.to_u64()));
602+
assert!((20i == 20f32.to_int()));
603+
assert!((20i8 == 20f32.to_i8()));
604+
assert!((20i16 == 20f32.to_i16()));
605+
assert!((20i32 == 20f32.to_i32()));
606+
assert!((20i64 == 20f32.to_i64()));
607+
assert!((20f == 20f32.to_float()));
608+
assert!((20f32 == 20f32.to_f32()));
609+
assert!((20f64 == 20f32.to_f64()));
610+
611+
assert!((20f32 == NumCast::from(20u)));
612+
assert!((20f32 == NumCast::from(20u8)));
613+
assert!((20f32 == NumCast::from(20u16)));
614+
assert!((20f32 == NumCast::from(20u32)));
615+
assert!((20f32 == NumCast::from(20u64)));
616+
assert!((20f32 == NumCast::from(20i)));
617+
assert!((20f32 == NumCast::from(20i8)));
618+
assert!((20f32 == NumCast::from(20i16)));
619+
assert!((20f32 == NumCast::from(20i32)));
620+
assert!((20f32 == NumCast::from(20i64)));
621+
assert!((20f32 == NumCast::from(20f)));
622+
assert!((20f32 == NumCast::from(20f32)));
623+
assert!((20f32 == NumCast::from(20f64)));
624+
625+
assert!((20f32 == num::cast(20u)));
626+
assert!((20f32 == num::cast(20u8)));
627+
assert!((20f32 == num::cast(20u16)));
628+
assert!((20f32 == num::cast(20u32)));
629+
assert!((20f32 == num::cast(20u64)));
630+
assert!((20f32 == num::cast(20i)));
631+
assert!((20f32 == num::cast(20i8)));
632+
assert!((20f32 == num::cast(20i16)));
633+
assert!((20f32 == num::cast(20i32)));
634+
assert!((20f32 == num::cast(20i64)));
635+
assert!((20f32 == num::cast(20f)));
636+
assert!((20f32 == num::cast(20f32)));
637+
assert!((20f32 == num::cast(20f64)));
638+
}
639+
558640
//
559641
// Local Variables:
560642
// mode: rust

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

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
1313
use cmath;
1414
use libc::{c_double, c_int};
15+
use num::NumCast;
1516
use num::strconv;
1617
use num;
1718
use option::Option;
@@ -298,6 +299,30 @@ impl cmp::Ord for f64 {
298299
fn gt(&self, other: &f64) -> bool { (*self) > (*other) }
299300
}
300301

302+
impl NumCast for f64 {
303+
/**
304+
* Cast `n` to an `f64`
305+
*/
306+
#[inline(always)]
307+
fn from<N:NumCast>(n: N) -> f64 { n.to_f64() }
308+
309+
#[inline(always)] fn to_u8(&self) -> u8 { *self as u8 }
310+
#[inline(always)] fn to_u16(&self) -> u16 { *self as u16 }
311+
#[inline(always)] fn to_u32(&self) -> u32 { *self as u32 }
312+
#[inline(always)] fn to_u64(&self) -> u64 { *self as u64 }
313+
#[inline(always)] fn to_uint(&self) -> uint { *self as uint }
314+
315+
#[inline(always)] fn to_i8(&self) -> i8 { *self as i8 }
316+
#[inline(always)] fn to_i16(&self) -> i16 { *self as i16 }
317+
#[inline(always)] fn to_i32(&self) -> i32 { *self as i32 }
318+
#[inline(always)] fn to_i64(&self) -> i64 { *self as i64 }
319+
#[inline(always)] fn to_int(&self) -> int { *self as int }
320+
321+
#[inline(always)] fn to_f32(&self) -> f32 { *self as f32 }
322+
#[inline(always)] fn to_f64(&self) -> f64 { *self }
323+
#[inline(always)] fn to_float(&self) -> float { *self as float }
324+
}
325+
301326
impl num::Zero for f64 {
302327
#[inline(always)]
303328
fn zero() -> f64 { 0.0 }
@@ -577,6 +602,63 @@ impl num::FromStrRadix for f64 {
577602
}
578603
}
579604

605+
#[test]
606+
pub fn test_num() {
607+
let ten: f64 = num::cast(10);
608+
let two: f64 = num::cast(2);
609+
610+
assert!((ten.add(&two) == num::cast(12)));
611+
assert!((ten.sub(&two) == num::cast(8)));
612+
assert!((ten.mul(&two) == num::cast(20)));
613+
assert!((ten.div(&two) == num::cast(5)));
614+
assert!((ten.modulo(&two) == num::cast(0)));
615+
}
616+
617+
#[test]
618+
fn test_numcast() {
619+
assert!((20u == 20f64.to_uint()));
620+
assert!((20u8 == 20f64.to_u8()));
621+
assert!((20u16 == 20f64.to_u16()));
622+
assert!((20u32 == 20f64.to_u32()));
623+
assert!((20u64 == 20f64.to_u64()));
624+
assert!((20i == 20f64.to_int()));
625+
assert!((20i8 == 20f64.to_i8()));
626+
assert!((20i16 == 20f64.to_i16()));
627+
assert!((20i32 == 20f64.to_i32()));
628+
assert!((20i64 == 20f64.to_i64()));
629+
assert!((20f == 20f64.to_float()));
630+
assert!((20f32 == 20f64.to_f32()));
631+
assert!((20f64 == 20f64.to_f64()));
632+
633+
assert!((20f64 == NumCast::from(20u)));
634+
assert!((20f64 == NumCast::from(20u8)));
635+
assert!((20f64 == NumCast::from(20u16)));
636+
assert!((20f64 == NumCast::from(20u32)));
637+
assert!((20f64 == NumCast::from(20u64)));
638+
assert!((20f64 == NumCast::from(20i)));
639+
assert!((20f64 == NumCast::from(20i8)));
640+
assert!((20f64 == NumCast::from(20i16)));
641+
assert!((20f64 == NumCast::from(20i32)));
642+
assert!((20f64 == NumCast::from(20i64)));
643+
assert!((20f64 == NumCast::from(20f)));
644+
assert!((20f64 == NumCast::from(20f32)));
645+
assert!((20f64 == NumCast::from(20f64)));
646+
647+
assert!((20f64 == num::cast(20u)));
648+
assert!((20f64 == num::cast(20u8)));
649+
assert!((20f64 == num::cast(20u16)));
650+
assert!((20f64 == num::cast(20u32)));
651+
assert!((20f64 == num::cast(20u64)));
652+
assert!((20f64 == num::cast(20i)));
653+
assert!((20f64 == num::cast(20i8)));
654+
assert!((20f64 == num::cast(20i16)));
655+
assert!((20f64 == num::cast(20i32)));
656+
assert!((20f64 == num::cast(20i64)));
657+
assert!((20f64 == num::cast(20f)));
658+
assert!((20f64 == num::cast(20f32)));
659+
assert!((20f64 == num::cast(20f64)));
660+
}
661+
580662
//
581663
// Local Variables:
582664
// mode: rust

0 commit comments

Comments
 (0)