Skip to content

Commit e0df3ba

Browse files
committed
---
yaml --- r: 128438 b: refs/heads/auto c: 776c17f h: refs/heads/master v: v3
1 parent 4839d7a commit e0df3ba

File tree

9 files changed

+73
-6
lines changed

9 files changed

+73
-6
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: 9b0f89d342de06b035c108186f0243a3bdc7528b
16+
refs/heads/auto: 776c17f476c4be92f6cfe4dab528886973ea8c03
1717
refs/heads/servo: af82457af293e2a842ba6b7759b70288da276167
1818
refs/tags/release-0.6: b4ebcfa1812664df5e142f0134a5faea3918544c
1919
refs/tags/0.1: b19db808c2793fe2976759b85a355c3ad8c8b336

branches/auto/src/etc/emacs/rust-mode.el

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -170,7 +170,7 @@
170170
(defconst rust-mode-keywords
171171
'("as"
172172
"box" "break"
173-
"continue" "crate"
173+
"const" "continue" "crate"
174174
"do"
175175
"else" "enum" "extern"
176176
"false" "fn" "for"
@@ -182,7 +182,8 @@
182182
"self" "static" "struct" "super"
183183
"true" "trait" "type"
184184
"unsafe" "use"
185-
"while"))
185+
"virtual"
186+
"where" "while"))
186187

187188
(defconst rust-special-types
188189
'("u8" "i8"

branches/auto/src/etc/gedit/share/gtksourceview-3.0/language-specs/rust.lang

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,8 @@
7171
<keyword>trait</keyword>
7272
<keyword>unsafe</keyword>
7373
<keyword>use</keyword>
74+
<keyword>virtual</keyword>
75+
<keyword>where</keyword>
7476
<keyword>while</keyword>
7577
</context>
7678

branches/auto/src/etc/kate/rust.xml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919
<item> as </item>
2020
<item> break </item>
2121
<item> box </item>
22+
<item> const </item>
2223
<item> continue </item>
2324
<item> crate </item>
2425
<item> do </item>
@@ -44,6 +45,8 @@
4445
<item> trait </item>
4546
<item> unsafe </item>
4647
<item> use </item>
48+
<item> virtual </item>
49+
<item> where </item>
4750
<item> while </item>
4851
</list>
4952
<list name="traits">

branches/auto/src/etc/vim/syntax/rust.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ syn keyword rustKeyword fn nextgroup=rustFuncName skipwhite skipempty
2626
syn keyword rustKeyword for in if impl let
2727
syn keyword rustKeyword loop once proc pub
2828
syn keyword rustKeyword return super
29-
syn keyword rustKeyword unsafe virtual while
29+
syn keyword rustKeyword unsafe virtual where while
3030
syn keyword rustKeyword use nextgroup=rustModPath,rustModPathInUse skipwhite skipempty
3131
" FIXME: Scoped impl's name is also fallen in this category
3232
syn keyword rustKeyword mod trait struct enum type nextgroup=rustIdentifier skipwhite skipempty

branches/auto/src/libcollections/bitv.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1271,7 +1271,7 @@ impl BitvSet {
12711271
/// let a = BitvSet::from_bitv(bitv::from_bytes([0b01101000]));
12721272
/// let b = BitvSet::from_bitv(bitv::from_bytes([0b10100000]));
12731273
///
1274-
/// // Print 2, 4 in arbitrary order
1274+
/// // Print 1, 4 in arbitrary order
12751275
/// for x in a.difference(&b) {
12761276
/// println!("{}", x);
12771277
/// }

branches/auto/src/libcollections/btree.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,13 @@
1111
// btree.rs
1212
//
1313

14+
// NB. this is not deprecated for removal, just deprecating the
15+
// current implementation. If the major pain-points are addressed
16+
// (overuse of by-value self and .clone), this can be removed.
17+
#![deprecated = "the current implementation is extremely inefficient, \
18+
prefer a HashMap, TreeMap or TrieMap"]
19+
#![allow(deprecated)]
20+
1421
//! Starting implementation of a btree for rust.
1522
//! Structure inspired by github user davidhalperin's gist.
1623

branches/auto/src/libnum/bigint.rs

Lines changed: 54 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@
5959
use Integer;
6060
use rand::Rng;
6161

62-
use std::{cmp, fmt};
62+
use std::{cmp, fmt, hash};
6363
use std::default::Default;
6464
use std::from_str::FromStr;
6565
use std::num::CheckedDiv;
@@ -150,6 +150,22 @@ impl Default for BigUint {
150150
fn default() -> BigUint { Zero::zero() }
151151
}
152152

153+
impl<S: hash::Writer> hash::Hash<S> for BigUint {
154+
fn hash(&self, state: &mut S) {
155+
// hash 0 in case it's all 0's
156+
0u32.hash(state);
157+
158+
let mut found_first_value = false;
159+
for elem in self.data.iter().rev() {
160+
// don't hash any leading 0's, they shouldn't affect the hash
161+
if found_first_value || *elem != 0 {
162+
found_first_value = true;
163+
elem.hash(state);
164+
}
165+
}
166+
}
167+
}
168+
153169
impl fmt::Show for BigUint {
154170
fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result {
155171
write!(f, "{}", self.to_str_radix(10))
@@ -881,6 +897,13 @@ impl fmt::Show for BigInt {
881897
}
882898
}
883899

900+
impl<S: hash::Writer> hash::Hash<S> for BigInt {
901+
fn hash(&self, state: &mut S) {
902+
(self.sign == Plus).hash(state);
903+
self.data.hash(state);
904+
}
905+
}
906+
884907
impl FromStr for BigInt {
885908
#[inline]
886909
fn from_str(s: &str) -> Option<BigInt> {
@@ -1409,6 +1432,7 @@ mod biguint_tests {
14091432
use std::num::CheckedDiv;
14101433
use std::rand::task_rng;
14111434
use std::u64;
1435+
use std::hash::hash;
14121436

14131437
#[test]
14141438
fn test_from_slice() {
@@ -1460,6 +1484,19 @@ mod biguint_tests {
14601484
}
14611485
}
14621486

1487+
#[test]
1488+
fn test_hash() {
1489+
let a = BigUint::new(vec!());
1490+
let b = BigUint::new(vec!(0));
1491+
let c = BigUint::new(vec!(1));
1492+
let d = BigUint::new(vec!(1,0,0,0,0,0));
1493+
let e = BigUint::new(vec!(0,0,0,0,0,1));
1494+
assert!(hash(&a) == hash(&b));
1495+
assert!(hash(&b) != hash(&c));
1496+
assert!(hash(&c) == hash(&d));
1497+
assert!(hash(&d) != hash(&e));
1498+
}
1499+
14631500
#[test]
14641501
fn test_bitand() {
14651502
fn check(left: &[BigDigit],
@@ -2257,6 +2294,7 @@ mod bigint_tests {
22572294
use std::num::{ToPrimitive, FromPrimitive};
22582295
use std::rand::task_rng;
22592296
use std::u64;
2297+
use std::hash::hash;
22602298

22612299
#[test]
22622300
fn test_from_biguint() {
@@ -2314,6 +2352,21 @@ mod bigint_tests {
23142352
}
23152353
}
23162354

2355+
#[test]
2356+
fn test_hash() {
2357+
let a = BigInt::new(Zero, vec!());
2358+
let b = BigInt::new(Zero, vec!(0));
2359+
let c = BigInt::new(Plus, vec!(1));
2360+
let d = BigInt::new(Plus, vec!(1,0,0,0,0,0));
2361+
let e = BigInt::new(Plus, vec!(0,0,0,0,0,1));
2362+
let f = BigInt::new(Minus, vec!(1));
2363+
assert!(hash(&a) == hash(&b));
2364+
assert!(hash(&b) != hash(&c));
2365+
assert!(hash(&c) == hash(&d));
2366+
assert!(hash(&d) != hash(&e));
2367+
assert!(hash(&c) != hash(&f));
2368+
}
2369+
23172370
#[test]
23182371
fn test_convert_i64() {
23192372
fn check(b1: BigInt, i: i64) {

branches/auto/src/libnum/lib.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,7 @@
4343
//! [newt]: https://en.wikipedia.org/wiki/Methods_of_computing_square_roots#Babylonian_method
4444
4545
#![feature(macro_rules)]
46+
#![feature(default_type_params)]
4647

4748
#![crate_name = "num"]
4849
#![experimental]

0 commit comments

Comments
 (0)