Skip to content

Commit fc37373

Browse files
committed
---
yaml --- r: 103486 b: refs/heads/auto c: fe50c75 h: refs/heads/master v: v3
1 parent cf103b1 commit fc37373

File tree

44 files changed

+559
-342
lines changed

Some content is hidden

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

44 files changed

+559
-342
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ refs/heads/try3: 9387340aab40a73e8424c48fd42f0c521a4875c0
1313
refs/tags/release-0.3.1: 495bae036dfe5ec6ceafd3312b4dca48741e845b
1414
refs/tags/release-0.4: e828ea2080499553b97dfe33b3f4d472b4562ad7
1515
refs/tags/release-0.5: 7e3bcfbf21278251ee936ad53e92e9b719702d73
16-
refs/heads/auto: 4d8295df6c7b6efa7ce27f2b59e30faf3028bf54
16+
refs/heads/auto: fe50c75d02c9b41bcda28596077b1122a89bee5d
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/doc/rust.css

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -111,11 +111,11 @@ h5 a:link, h5 a:visited {color: black;}
111111
/* Code
112112
========================================================================== */
113113
pre, code {
114-
font-family: Menlo, Monaco, Consolas, "Courier New", monospace;
114+
font-family: Menlo, Monaco, Consolas, "DejaVu Sans Mono", monospace;
115115
border-radius: 4px;
116116
}
117117
pre {
118-
background-color: #F5F5F5;
118+
background-color: #FDFDFD;
119119
border: 1px solid #CCC;
120120
border-radius: 0.5em;
121121
white-space: pre-wrap;
@@ -142,24 +142,24 @@ pre code {
142142
}
143143

144144
/* Code highlighting */
145-
.cm-s-default span.cm-keyword {color: #803C8D;}
145+
.cm-s-default span.cm-keyword {color: #8959A8;}
146146
.cm-s-default span.cm-atom {color: #219;}
147-
.cm-s-default span.cm-number {color: #2AA198;}
148-
.cm-s-default span.cm-def {color: #256EB8;}
149-
.cm-s-default span.cm-variable {color: black;}
150-
.cm-s-default span.cm-variable-2 {color: #817E61;}
151-
.cm-s-default span.cm-variable-3 {color: #085;}
147+
.cm-s-default span.cm-number {color: #3E999F;}
148+
.cm-s-default span.cm-def {color: #4271AE;}
149+
/*.cm-s-default span.cm-variable {color: #C82829;}*/
150+
.cm-s-default span.cm-variable-2 {color: #6F906C;}
151+
.cm-s-default span.cm-variable-3 {color: #B76514;}
152152
.cm-s-default span.cm-property {color: black;}
153153
.cm-s-default span.cm-operator {color: black;}
154-
.cm-s-default span.cm-comment {color: #A82323;}
155-
.cm-s-default span.cm-string {color: #866544;}
156-
.cm-s-default span.cm-string-2 {color: #F50;}
154+
.cm-s-default span.cm-comment {color: #8E908C;}
155+
.cm-s-default span.cm-string {color: #718C00;}
156+
.cm-s-default span.cm-string-2 {color: #866544;}
157157
.cm-s-default span.cm-meta {color: #555;}
158158
/*.cm-s-default span.cm-error {color: #F00;}*/
159159
.cm-s-default span.cm-qualifier {color: #555;}
160160
.cm-s-default span.cm-builtin {color: #30A;}
161161
.cm-s-default span.cm-bracket {color: #CC7;}
162-
.cm-s-default span.cm-tag {color: #170;}
162+
.cm-s-default span.cm-tag {color: #C82829;}
163163
.cm-s-default span.cm-attribute {color: #00C;}
164164

165165
/* The rest

branches/auto/src/doc/rustdoc.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ is how the above advertisement works. An example from the `libstd`
6363
documentation:
6464

6565
~~~
66-
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
66+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
6767
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
6868
html_root_url = "http://static.rust-lang.org/doc/master")];
6969
~~~

branches/auto/src/libextra/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ Rust extras are part of the standard Rust distribution.
2525
#[license = "MIT/ASL2"];
2626
#[crate_type = "rlib"];
2727
#[crate_type = "dylib"];
28-
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
28+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
2929
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
3030
html_root_url = "http://static.rust-lang.org/doc/master")];
3131

branches/auto/src/libgreen/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,7 +167,7 @@
167167
#[license = "MIT/ASL2"];
168168
#[crate_type = "rlib"];
169169
#[crate_type = "dylib"];
170-
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
170+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
171171
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
172172
html_root_url = "http://static.rust-lang.org/doc/master")];
173173

branches/auto/src/libgreen/simple.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
//! A small module implementing a simple "runtime" used for bootstrapping a rust
1212
//! scheduler pool and then interacting with it.
1313
14+
use std::any::Any;
1415
use std::cast;
1516
use std::rt::Runtime;
1617
use std::rt::local::Local;

branches/auto/src/libgreen/task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@
1818
//! contains the rust task itself in order to juggle around ownership of the
1919
//! values.
2020
21+
use std::any::Any;
2122
use std::cast;
2223
use std::rt::env;
2324
use std::rt::Runtime;

branches/auto/src/libnative/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@
4545
#[license = "MIT/ASL2"];
4646
#[crate_type = "rlib"];
4747
#[crate_type = "dylib"];
48-
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk.png",
48+
#[doc(html_logo_url = "http://www.rust-lang.org/logos/rust-logo-128x128-blk-v2.png",
4949
html_favicon_url = "http://www.rust-lang.org/favicon.ico",
5050
html_root_url = "http://static.rust-lang.org/doc/master")];
5151
#[deny(unused_result, unused_must_use)];

branches/auto/src/libnative/task.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
//! by rust tasks. This implements the necessary API traits laid out by std::rt
1515
//! in order to spawn new tasks and deschedule the current task.
1616
17+
use std::any::Any;
1718
use std::cast;
1819
use std::rt::env;
1920
use std::rt::local::Local;

branches/auto/src/libnum/bigint.rs

Lines changed: 233 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ use Integer;
2121
use std::cmp;
2222
use std::fmt;
2323
use std::from_str::FromStr;
24+
use std::num::CheckedDiv;
2425
use std::num::{Bitwise, ToPrimitive, FromPrimitive};
2526
use std::num::{Zero, One, ToStrRadix, FromStrRadix};
2627
use std::rand::Rng;
@@ -338,6 +339,40 @@ impl Neg<BigUint> for BigUint {
338339
fn neg(&self) -> BigUint { fail!() }
339340
}
340341

342+
impl CheckedAdd for BigUint {
343+
#[inline]
344+
fn checked_add(&self, v: &BigUint) -> Option<BigUint> {
345+
return Some(self.add(v));
346+
}
347+
}
348+
349+
impl CheckedSub for BigUint {
350+
#[inline]
351+
fn checked_sub(&self, v: &BigUint) -> Option<BigUint> {
352+
if *self < *v {
353+
return None;
354+
}
355+
return Some(self.sub(v));
356+
}
357+
}
358+
359+
impl CheckedMul for BigUint {
360+
#[inline]
361+
fn checked_mul(&self, v: &BigUint) -> Option<BigUint> {
362+
return Some(self.mul(v));
363+
}
364+
}
365+
366+
impl CheckedDiv for BigUint {
367+
#[inline]
368+
fn checked_div(&self, v: &BigUint) -> Option<BigUint> {
369+
if v.is_zero() {
370+
return None;
371+
}
372+
return Some(self.div(v));
373+
}
374+
}
375+
341376
impl Integer for BigUint {
342377
#[inline]
343378
fn div_rem(&self, other: &BigUint) -> (BigUint, BigUint) {
@@ -1053,6 +1088,38 @@ impl Neg<BigInt> for BigInt {
10531088
}
10541089
}
10551090

1091+
impl CheckedAdd for BigInt {
1092+
#[inline]
1093+
fn checked_add(&self, v: &BigInt) -> Option<BigInt> {
1094+
return Some(self.add(v));
1095+
}
1096+
}
1097+
1098+
impl CheckedSub for BigInt {
1099+
#[inline]
1100+
fn checked_sub(&self, v: &BigInt) -> Option<BigInt> {
1101+
return Some(self.sub(v));
1102+
}
1103+
}
1104+
1105+
impl CheckedMul for BigInt {
1106+
#[inline]
1107+
fn checked_mul(&self, v: &BigInt) -> Option<BigInt> {
1108+
return Some(self.mul(v));
1109+
}
1110+
}
1111+
1112+
impl CheckedDiv for BigInt {
1113+
#[inline]
1114+
fn checked_div(&self, v: &BigInt) -> Option<BigInt> {
1115+
if v.is_zero() {
1116+
return None;
1117+
}
1118+
return Some(self.div(v));
1119+
}
1120+
}
1121+
1122+
10561123
impl Integer for BigInt {
10571124
#[inline]
10581125
fn div_rem(&self, other: &BigInt) -> (BigInt, BigInt) {
@@ -1402,6 +1469,7 @@ mod biguint_tests {
14021469
use std::i64;
14031470
use std::num::{Zero, One, FromStrRadix, ToStrRadix};
14041471
use std::num::{ToPrimitive, FromPrimitive};
1472+
use std::num::CheckedDiv;
14051473
use std::rand::{task_rng};
14061474
use std::str;
14071475
use std::u64;
@@ -1822,6 +1890,82 @@ mod biguint_tests {
18221890
}
18231891
}
18241892

1893+
#[test]
1894+
fn test_checked_add() {
1895+
for elm in sum_triples.iter() {
1896+
let (aVec, bVec, cVec) = *elm;
1897+
let a = BigUint::from_slice(aVec);
1898+
let b = BigUint::from_slice(bVec);
1899+
let c = BigUint::from_slice(cVec);
1900+
1901+
assert!(a.checked_add(&b).unwrap() == c);
1902+
assert!(b.checked_add(&a).unwrap() == c);
1903+
}
1904+
}
1905+
1906+
#[test]
1907+
fn test_checked_sub() {
1908+
for elm in sum_triples.iter() {
1909+
let (aVec, bVec, cVec) = *elm;
1910+
let a = BigUint::from_slice(aVec);
1911+
let b = BigUint::from_slice(bVec);
1912+
let c = BigUint::from_slice(cVec);
1913+
1914+
assert!(c.checked_sub(&a).unwrap() == b);
1915+
assert!(c.checked_sub(&b).unwrap() == a);
1916+
1917+
if a > c {
1918+
assert!(a.checked_sub(&c).is_none());
1919+
}
1920+
if b > c {
1921+
assert!(b.checked_sub(&c).is_none());
1922+
}
1923+
}
1924+
}
1925+
1926+
#[test]
1927+
fn test_checked_mul() {
1928+
for elm in mul_triples.iter() {
1929+
let (aVec, bVec, cVec) = *elm;
1930+
let a = BigUint::from_slice(aVec);
1931+
let b = BigUint::from_slice(bVec);
1932+
let c = BigUint::from_slice(cVec);
1933+
1934+
assert!(a.checked_mul(&b).unwrap() == c);
1935+
assert!(b.checked_mul(&a).unwrap() == c);
1936+
}
1937+
1938+
for elm in div_rem_quadruples.iter() {
1939+
let (aVec, bVec, cVec, dVec) = *elm;
1940+
let a = BigUint::from_slice(aVec);
1941+
let b = BigUint::from_slice(bVec);
1942+
let c = BigUint::from_slice(cVec);
1943+
let d = BigUint::from_slice(dVec);
1944+
1945+
assert!(a == b.checked_mul(&c).unwrap() + d);
1946+
assert!(a == c.checked_mul(&b).unwrap() + d);
1947+
}
1948+
}
1949+
1950+
#[test]
1951+
fn test_checked_div() {
1952+
for elm in mul_triples.iter() {
1953+
let (aVec, bVec, cVec) = *elm;
1954+
let a = BigUint::from_slice(aVec);
1955+
let b = BigUint::from_slice(bVec);
1956+
let c = BigUint::from_slice(cVec);
1957+
1958+
if !a.is_zero() {
1959+
assert!(c.checked_div(&a).unwrap() == b);
1960+
}
1961+
if !b.is_zero() {
1962+
assert!(c.checked_div(&b).unwrap() == a);
1963+
}
1964+
1965+
assert!(c.checked_div(&Zero::zero()).is_none());
1966+
}
1967+
}
1968+
18251969
#[test]
18261970
fn test_gcd() {
18271971
fn check(a: uint, b: uint, c: uint) {
@@ -2058,6 +2202,7 @@ mod bigint_tests {
20582202

20592203
use std::cmp::{Less, Equal, Greater};
20602204
use std::i64;
2205+
use std::num::CheckedDiv;
20612206
use std::num::{Zero, One, FromStrRadix, ToStrRadix};
20622207
use std::num::{ToPrimitive, FromPrimitive};
20632208
use std::rand::{task_rng};
@@ -2399,6 +2544,94 @@ mod bigint_tests {
23992544
}
24002545
}
24012546

2547+
#[test]
2548+
fn test_checked_add() {
2549+
for elm in sum_triples.iter() {
2550+
let (aVec, bVec, cVec) = *elm;
2551+
let a = BigInt::from_slice(Plus, aVec);
2552+
let b = BigInt::from_slice(Plus, bVec);
2553+
let c = BigInt::from_slice(Plus, cVec);
2554+
2555+
assert!(a.checked_add(&b).unwrap() == c);
2556+
assert!(b.checked_add(&a).unwrap() == c);
2557+
assert!(c.checked_add(&(-a)).unwrap() == b);
2558+
assert!(c.checked_add(&(-b)).unwrap() == a);
2559+
assert!(a.checked_add(&(-c)).unwrap() == (-b));
2560+
assert!(b.checked_add(&(-c)).unwrap() == (-a));
2561+
assert!((-a).checked_add(&(-b)).unwrap() == (-c))
2562+
assert!(a.checked_add(&(-a)).unwrap() == Zero::zero());
2563+
}
2564+
}
2565+
2566+
#[test]
2567+
fn test_checked_sub() {
2568+
for elm in sum_triples.iter() {
2569+
let (aVec, bVec, cVec) = *elm;
2570+
let a = BigInt::from_slice(Plus, aVec);
2571+
let b = BigInt::from_slice(Plus, bVec);
2572+
let c = BigInt::from_slice(Plus, cVec);
2573+
2574+
assert!(c.checked_sub(&a).unwrap() == b);
2575+
assert!(c.checked_sub(&b).unwrap() == a);
2576+
assert!((-b).checked_sub(&a).unwrap() == (-c))
2577+
assert!((-a).checked_sub(&b).unwrap() == (-c))
2578+
assert!(b.checked_sub(&(-a)).unwrap() == c);
2579+
assert!(a.checked_sub(&(-b)).unwrap() == c);
2580+
assert!((-c).checked_sub(&(-a)).unwrap() == (-b));
2581+
assert!(a.checked_sub(&a).unwrap() == Zero::zero());
2582+
}
2583+
}
2584+
2585+
#[test]
2586+
fn test_checked_mul() {
2587+
for elm in mul_triples.iter() {
2588+
let (aVec, bVec, cVec) = *elm;
2589+
let a = BigInt::from_slice(Plus, aVec);
2590+
let b = BigInt::from_slice(Plus, bVec);
2591+
let c = BigInt::from_slice(Plus, cVec);
2592+
2593+
assert!(a.checked_mul(&b).unwrap() == c);
2594+
assert!(b.checked_mul(&a).unwrap() == c);
2595+
2596+
assert!((-a).checked_mul(&b).unwrap() == -c);
2597+
assert!((-b).checked_mul(&a).unwrap() == -c);
2598+
}
2599+
2600+
for elm in div_rem_quadruples.iter() {
2601+
let (aVec, bVec, cVec, dVec) = *elm;
2602+
let a = BigInt::from_slice(Plus, aVec);
2603+
let b = BigInt::from_slice(Plus, bVec);
2604+
let c = BigInt::from_slice(Plus, cVec);
2605+
let d = BigInt::from_slice(Plus, dVec);
2606+
2607+
assert!(a == b.checked_mul(&c).unwrap() + d);
2608+
assert!(a == c.checked_mul(&b).unwrap() + d);
2609+
}
2610+
}
2611+
#[test]
2612+
fn test_checked_div() {
2613+
for elm in mul_triples.iter() {
2614+
let (aVec, bVec, cVec) = *elm;
2615+
let a = BigInt::from_slice(Plus, aVec);
2616+
let b = BigInt::from_slice(Plus, bVec);
2617+
let c = BigInt::from_slice(Plus, cVec);
2618+
2619+
if !a.is_zero() {
2620+
assert!(c.checked_div(&a).unwrap() == b);
2621+
assert!((-c).checked_div(&(-a)).unwrap() == b);
2622+
assert!((-c).checked_div(&a).unwrap() == -b);
2623+
}
2624+
if !b.is_zero() {
2625+
assert!(c.checked_div(&b).unwrap() == a);
2626+
assert!((-c).checked_div(&(-b)).unwrap() == a);
2627+
assert!((-c).checked_div(&b).unwrap() == -a);
2628+
}
2629+
2630+
assert!(c.checked_div(&Zero::zero()).is_none());
2631+
assert!((-c).checked_div(&Zero::zero()).is_none());
2632+
}
2633+
}
2634+
24022635
#[test]
24032636
fn test_gcd() {
24042637
fn check(a: int, b: int, c: int) {

0 commit comments

Comments
 (0)