Skip to content

Commit 6dc112b

Browse files
committed
---
yaml --- r: 64675 b: refs/heads/snap-stage3 c: 359755a h: refs/heads/master i: 64673: bad694e 64671: a59e9c7 v: v3
1 parent 34e2332 commit 6dc112b

35 files changed

+813
-865
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: 17e30d6b4ef5c6fb4d6257323903cba1213cae8f
4+
refs/heads/snap-stage3: 359755a39a1d216a03a4e4d0b14e64e6610bbf91
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/etc/emacs/README.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,8 @@ marking, press x, and ELPA will install the packages for you (under
9898
~/.emacs.d/elpa/).
9999

100100
* or using <kbd>M-x package-install rust-mode
101+
102+
### Known bugs
103+
104+
* Combining `global-whitespace-mode` and `rust-mode` is generally glitchy.
105+
See [Issue #3994](https://github.com/mozilla/rust/issues/3994).

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

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ pub enum Json {
4141
}
4242

4343
pub type List = ~[Json];
44-
pub type Object = HashMap<~str, Json>;
44+
pub type Object = TreeMap<~str, Json>;
4545

4646
#[deriving(Eq)]
4747
/// If an error occurs while parsing some JSON, this is the structure which is
@@ -809,7 +809,7 @@ impl<T : iterator::Iterator<char>> Parser<T> {
809809
self.bump();
810810
self.parse_whitespace();
811811

812-
let mut values = ~HashMap::new();
812+
let mut values = ~TreeMap::new();
813813

814814
if self.ch == '}' {
815815
self.bump();
@@ -1087,7 +1087,7 @@ impl serialize::Decoder for Decoder {
10871087
let len = match self.stack.pop() {
10881088
Object(obj) => {
10891089
let len = obj.len();
1090-
for obj.consume().advance |(key, value)| {
1090+
for obj.consume_iter().advance |(key, value)| {
10911091
self.stack.push(value);
10921092
self.stack.push(String(key));
10931093
}
@@ -1294,19 +1294,19 @@ impl<A:ToJson> ToJson for ~[A] {
12941294
fn to_json(&self) -> Json { List(self.map(|elt| elt.to_json())) }
12951295
}
12961296

1297-
impl<A:ToJson> ToJson for HashMap<~str, A> {
1297+
impl<A:ToJson> ToJson for TreeMap<~str, A> {
12981298
fn to_json(&self) -> Json {
1299-
let mut d = HashMap::new();
1299+
let mut d = TreeMap::new();
13001300
for self.iter().advance |(key, value)| {
13011301
d.insert((*key).clone(), value.to_json());
13021302
}
13031303
Object(~d)
13041304
}
13051305
}
13061306

1307-
impl<A:ToJson> ToJson for TreeMap<~str, A> {
1307+
impl<A:ToJson> ToJson for HashMap<~str, A> {
13081308
fn to_json(&self) -> Json {
1309-
let mut d = HashMap::new();
1309+
let mut d = TreeMap::new();
13101310
for self.iter().advance |(key, value)| {
13111311
d.insert((*key).clone(), value.to_json());
13121312
}
@@ -1338,11 +1338,11 @@ mod tests {
13381338

13391339
use super::*;
13401340

1341-
use std::hashmap::HashMap;
13421341
use std::io;
13431342
use std::result;
13441343

1345-
use extra::serialize::Decodable;
1344+
use serialize::Decodable;
1345+
use treemap::TreeMap;
13461346

13471347
#[deriving(Eq, Encodable, Decodable)]
13481348
enum Animal {
@@ -1363,7 +1363,7 @@ mod tests {
13631363
}
13641364

13651365
fn mk_object(items: &[(~str, Json)]) -> Json {
1366-
let mut d = ~HashMap::new();
1366+
let mut d = ~TreeMap::new();
13671367

13681368
for items.iter().advance |item| {
13691369
match *item {
@@ -1954,7 +1954,7 @@ mod tests {
19541954
fn test_decode_map() {
19551955
let s = ~"{\"a\": \"Dog\", \"b\": [\"Frog\", \"Henry\", 349]}";
19561956
let mut decoder = Decoder(from_str(s).unwrap());
1957-
let mut map: HashMap<~str, Animal> = Decodable::decode(&mut decoder);
1957+
let mut map: TreeMap<~str, Animal> = Decodable::decode(&mut decoder);
19581958
19591959
assert_eq!(map.pop(&~"a"), Some(Dog));
19601960
assert_eq!(map.pop(&~"b"), Some(Frog(~"Henry", 349)));

branches/snap-stage3/src/libextra/num/bigint.rs

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -732,11 +732,6 @@ impl Ord for Sign {
732732
}
733733
}
734734

735-
impl TotalEq for Sign {
736-
fn equals(&self, other: &Sign) -> bool {
737-
*self == *other
738-
}
739-
}
740735
impl TotalOrd for Sign {
741736

742737
fn cmp(&self, other: &Sign) -> Ordering {

branches/snap-stage3/src/libextra/num/rational.rs

Lines changed: 0 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -110,25 +110,6 @@ cmp_impl!(impl TotalEq, equals)
110110
cmp_impl!(impl Ord, lt, gt, le, ge)
111111
cmp_impl!(impl TotalOrd, cmp -> cmp::Ordering)
112112

113-
impl<T: Clone + Integer + Ord> Orderable for Ratio<T> {
114-
#[inline]
115-
fn min(&self, other: &Ratio<T>) -> Ratio<T> {
116-
if *self < *other { self.clone() } else { other.clone() }
117-
}
118-
119-
#[inline]
120-
fn max(&self, other: &Ratio<T>) -> Ratio<T> {
121-
if *self > *other { self.clone() } else { other.clone() }
122-
}
123-
124-
#[inline]
125-
fn clamp(&self, mn: &Ratio<T>, mx: &Ratio<T>) -> Ratio<T> {
126-
if *self > *mx { mx.clone()} else
127-
if *self < *mn { mn.clone() } else { self.clone() }
128-
}
129-
}
130-
131-
132113
/* Arithmetic */
133114
// a/b * c/d = (a*c)/(b*d)
134115
impl<T: Clone + Integer + Ord>

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,6 @@ use std::task;
3838
use std::to_str::ToStr;
3939
use std::u64;
4040
use std::f64;
41-
use std::hashmap::HashMap;
4241
use std::os;
4342

4443

@@ -852,7 +851,7 @@ fn calc_result(desc: &TestDesc, task_succeeded: bool) -> TestResult {
852851

853852
impl ToJson for Metric {
854853
fn to_json(&self) -> json::Json {
855-
let mut map = ~HashMap::new();
854+
let mut map = ~TreeMap::new();
856855
map.insert(~"value", json::Number(self.value as float));
857856
map.insert(~"noise", json::Number(self.noise as float));
858857
json::Object(map)

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

Lines changed: 63 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,19 @@ impl<K: TotalOrd, V> TreeMap<K, V> {
204204
pub fn iter<'a>(&'a self) -> TreeMapIterator<'a, K, V> {
205205
TreeMapIterator{stack: ~[], node: &self.root, remaining: self.length}
206206
}
207+
208+
/// Get a lazy iterator that consumes the treemap.
209+
pub fn consume_iter(self) -> TreeMapConsumeIterator<K, V> {
210+
let TreeMap { root: root, length: length } = self;
211+
let stk = match root {
212+
None => ~[],
213+
Some(~tn) => ~[tn]
214+
};
215+
TreeMapConsumeIterator {
216+
stack: stk,
217+
remaining: length
218+
}
219+
}
207220
}
208221

209222
/// Lazy forward iterator over a map
@@ -241,6 +254,56 @@ impl<'self, K, V> Iterator<(&'self K, &'self V)> for TreeMapIterator<'self, K, V
241254
}
242255
}
243256

257+
/// Lazy forward iterator over a map that consumes the map while iterating
258+
pub struct TreeMapConsumeIterator<K, V> {
259+
priv stack: ~[TreeNode<K, V>],
260+
priv remaining: uint
261+
}
262+
263+
impl<K, V> Iterator<(K, V)> for TreeMapConsumeIterator<K,V> {
264+
#[inline]
265+
fn next(&mut self) -> Option<(K, V)> {
266+
while !self.stack.is_empty() {
267+
let TreeNode {
268+
key: key,
269+
value: value,
270+
left: left,
271+
right: right,
272+
level: level
273+
} = self.stack.pop();
274+
275+
match left {
276+
Some(~left) => {
277+
let n = TreeNode {
278+
key: key,
279+
value: value,
280+
left: None,
281+
right: right,
282+
level: level
283+
};
284+
self.stack.push(n);
285+
self.stack.push(left);
286+
}
287+
None => {
288+
match right {
289+
Some(~right) => self.stack.push(right),
290+
None => ()
291+
}
292+
self.remaining -= 1;
293+
return Some((key, value))
294+
}
295+
}
296+
}
297+
None
298+
}
299+
300+
#[inline]
301+
fn size_hint(&self) -> (uint, Option<uint>) {
302+
(self.remaining, Some(self.remaining))
303+
}
304+
305+
}
306+
244307
impl<'self, T> Iterator<&'self T> for TreeSetIterator<'self, T> {
245308
/// Advance the iterator to the next node (in order). If there are no more nodes, return `None`.
246309
#[inline]

0 commit comments

Comments
 (0)