Skip to content

Commit 0a505c3

Browse files
committed
---
yaml --- r: 114302 b: refs/heads/master c: 564b925 h: refs/heads/master v: v3
1 parent 012fcb0 commit 0a505c3

File tree

9 files changed

+98
-107
lines changed

9 files changed

+98
-107
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
---
2-
refs/heads/master: e8c579e01d026df002fe6522d6f9c123b3920dc8
2+
refs/heads/master: 564b9250362cc7bb0f40320bf2cedc58ec47b077
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: ec0258a381b88b5574e3f8ce72ae553ac3a574b7
55
refs/heads/try: 7c6c492fb2af9a85f21ff952942df3523b22fd17

trunk/src/doc/rust.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2943,7 +2943,7 @@ See [Break expressions](#break-expressions) and [Continue expressions](#continue
29432943
break_expr : "break" [ lifetime ];
29442944
~~~~
29452945

2946-
A `break` expression has an optional _label_.
2946+
A `break` expression has an optional `label`.
29472947
If the label is absent, then executing a `break` expression immediately terminates the innermost loop enclosing it.
29482948
It is only permitted in the body of a loop.
29492949
If the label is present, then `break foo` terminates the loop with label `foo`,
@@ -2956,7 +2956,7 @@ but must enclose it.
29562956
continue_expr : "continue" [ lifetime ];
29572957
~~~~
29582958

2959-
A `continue` expression has an optional _label_.
2959+
A `continue` expression has an optional `label`.
29602960
If the label is absent,
29612961
then executing a `continue` expression immediately terminates the current iteration of the innermost loop enclosing it,
29622962
returning control to the loop *head*.
@@ -3115,7 +3115,7 @@ let x: List<int> = Cons(10, box Cons(11, box Nil));
31153115
31163116
match x {
31173117
Cons(a, box Cons(b, _)) => {
3118-
process_pair(a, b);
3118+
process_pair(a,b);
31193119
}
31203120
Cons(10, _) => {
31213121
process_ten();
@@ -3329,8 +3329,8 @@ order specified by the tuple type.
33293329
An example of a tuple type and its use:
33303330

33313331
~~~~
3332-
type Pair<'a> = (int, &'a str);
3333-
let p: Pair<'static> = (10, "hello");
3332+
type Pair<'a> = (int,&'a str);
3333+
let p: Pair<'static> = (10,"hello");
33343334
let (a, b) = p;
33353335
assert!(b != "world");
33363336
~~~~

trunk/src/doc/tutorial.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2602,7 +2602,7 @@ fn main() {
26022602
~~~
26032603

26042604
The full list of derivable traits is `Eq`, `TotalEq`, `Ord`,
2605-
`TotalOrd`, `Encodable`, `Decodable`, `Clone`,
2605+
`TotalOrd`, `Encodable` `Decodable`, `Clone`,
26062606
`Hash`, `Rand`, `Default`, `Zero`, `FromPrimitive` and `Show`.
26072607

26082608
# Crates and the module system

trunk/src/libcollections/dlist.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -410,7 +410,7 @@ impl<T> DList<T> {
410410
}
411411
}
412412

413-
impl<T: TotalOrd> DList<T> {
413+
impl<T: Ord> DList<T> {
414414
/// Insert `elt` sorted in ascending order
415415
///
416416
/// O(N)

trunk/src/libcollections/priority_queue.rs

Lines changed: 70 additions & 72 deletions
Original file line numberDiff line numberDiff line change
@@ -22,30 +22,30 @@ pub struct PriorityQueue<T> {
2222
data: Vec<T>,
2323
}
2424

25-
impl<T: TotalOrd> Container for PriorityQueue<T> {
25+
impl<T:Ord> Container for PriorityQueue<T> {
2626
/// Returns the length of the queue
2727
fn len(&self) -> uint { self.data.len() }
2828
}
2929

30-
impl<T: TotalOrd> Mutable for PriorityQueue<T> {
30+
impl<T:Ord> Mutable for PriorityQueue<T> {
3131
/// Drop all items from the queue
3232
fn clear(&mut self) { self.data.truncate(0) }
3333
}
3434

35-
impl<T: TotalOrd> PriorityQueue<T> {
35+
impl<T:Ord> PriorityQueue<T> {
3636
/// An iterator visiting all values in underlying vector, in
3737
/// arbitrary order.
3838
pub fn iter<'a>(&'a self) -> Items<'a, T> {
3939
Items { iter: self.data.iter() }
4040
}
4141

42-
/// Returns the greatest item in a queue or None if it is empty
43-
pub fn top<'a>(&'a self) -> Option<&'a T> {
44-
if self.is_empty() { None } else { Some(self.data.get(0)) }
45-
}
42+
/// Returns the greatest item in the queue - fails if empty
43+
pub fn top<'a>(&'a self) -> &'a T { self.data.get(0) }
4644

47-
#[deprecated="renamed to `top`"]
48-
pub fn maybe_top<'a>(&'a self) -> Option<&'a T> { self.top() }
45+
/// Returns the greatest item in the queue - None if empty
46+
pub fn maybe_top<'a>(&'a self) -> Option<&'a T> {
47+
if self.is_empty() { None } else { Some(self.top()) }
48+
}
4949

5050
/// Returns the number of elements the queue can hold without reallocating
5151
pub fn capacity(&self) -> uint { self.data.capacity() }
@@ -60,23 +60,20 @@ impl<T: TotalOrd> PriorityQueue<T> {
6060
self.data.reserve(n)
6161
}
6262

63-
/// Remove the greatest item from a queue and return it, or `None` if it is
64-
/// empty.
65-
pub fn pop(&mut self) -> Option<T> {
66-
match self.data.pop() {
67-
None => { None }
68-
Some(mut item) => {
69-
if !self.is_empty() {
70-
swap(&mut item, self.data.get_mut(0));
71-
self.siftdown(0);
72-
}
73-
Some(item)
74-
}
63+
/// Pop the greatest item from the queue - fails if empty
64+
pub fn pop(&mut self) -> T {
65+
let mut item = self.data.pop().unwrap();
66+
if !self.is_empty() {
67+
swap(&mut item, self.data.get_mut(0));
68+
self.siftdown(0);
7569
}
70+
item
7671
}
7772

78-
#[deprecated="renamed to `pop`"]
79-
pub fn maybe_pop(&mut self) -> Option<T> { self.pop() }
73+
/// Pop the greatest item from the queue - None if empty
74+
pub fn maybe_pop(&mut self) -> Option<T> {
75+
if self.is_empty() { None } else { Some(self.pop()) }
76+
}
8077

8178
/// Push an item onto the queue
8279
pub fn push(&mut self, item: T) {
@@ -87,48 +84,34 @@ impl<T: TotalOrd> PriorityQueue<T> {
8784

8885
/// Optimized version of a push followed by a pop
8986
pub fn push_pop(&mut self, mut item: T) -> T {
90-
if !self.is_empty() && *self.top().unwrap() > item {
87+
if !self.is_empty() && *self.top() > item {
9188
swap(&mut item, self.data.get_mut(0));
9289
self.siftdown(0);
9390
}
9491
item
9592
}
9693

97-
/// Optimized version of a pop followed by a push. The push is done
98-
/// regardless of whether the queue is empty.
99-
pub fn replace(&mut self, mut item: T) -> Option<T> {
100-
if !self.is_empty() {
101-
swap(&mut item, self.data.get_mut(0));
102-
self.siftdown(0);
103-
Some(item)
104-
} else {
105-
self.push(item);
106-
None
107-
}
94+
/// Optimized version of a pop followed by a push - fails if empty
95+
pub fn replace(&mut self, mut item: T) -> T {
96+
swap(&mut item, self.data.get_mut(0));
97+
self.siftdown(0);
98+
item
10899
}
109100

110-
#[allow(dead_code)]
111-
#[deprecated="renamed to `into_vec`"]
112-
fn to_vec(self) -> Vec<T> { self.into_vec() }
113-
114-
#[allow(dead_code)]
115-
#[deprecated="renamed to `into_sorted_vec`"]
116-
fn to_sorted_vec(self) -> Vec<T> { self.into_sorted_vec() }
117-
118101
/// Consume the PriorityQueue and return the underlying vector
119-
pub fn into_vec(self) -> Vec<T> { let PriorityQueue{data: v} = self; v }
102+
pub fn to_vec(self) -> Vec<T> { let PriorityQueue{data: v} = self; v }
120103

121104
/// Consume the PriorityQueue and return a vector in sorted
122105
/// (ascending) order
123-
pub fn into_sorted_vec(self) -> Vec<T> {
106+
pub fn to_sorted_vec(self) -> Vec<T> {
124107
let mut q = self;
125108
let mut end = q.len();
126109
while end > 1 {
127110
end -= 1;
128111
q.data.as_mut_slice().swap(0, end);
129112
q.siftdown_range(0, end)
130113
}
131-
q.into_vec()
114+
q.to_vec()
132115
}
133116

134117
/// Create an empty PriorityQueue
@@ -214,15 +197,15 @@ impl<'a, T> Iterator<&'a T> for Items<'a, T> {
214197
fn size_hint(&self) -> (uint, Option<uint>) { self.iter.size_hint() }
215198
}
216199

217-
impl<T: TotalOrd> FromIterator<T> for PriorityQueue<T> {
200+
impl<T: Ord> FromIterator<T> for PriorityQueue<T> {
218201
fn from_iter<Iter: Iterator<T>>(iter: Iter) -> PriorityQueue<T> {
219202
let mut q = PriorityQueue::new();
220203
q.extend(iter);
221204
q
222205
}
223206
}
224207

225-
impl<T: TotalOrd> Extendable<T> for PriorityQueue<T> {
208+
impl<T: Ord> Extendable<T> for PriorityQueue<T> {
226209
fn extend<Iter: Iterator<T>>(&mut self, mut iter: Iter) {
227210
let (lower, _) = iter.size_hint();
228211

@@ -258,53 +241,53 @@ mod tests {
258241
sorted.sort();
259242
let mut heap = PriorityQueue::from_vec(data);
260243
while !heap.is_empty() {
261-
assert_eq!(heap.top().unwrap(), sorted.last().unwrap());
262-
assert_eq!(heap.pop().unwrap(), sorted.pop().unwrap());
244+
assert_eq!(heap.top(), sorted.last().unwrap());
245+
assert_eq!(heap.pop(), sorted.pop().unwrap());
263246
}
264247
}
265248

266249
#[test]
267250
fn test_push() {
268251
let mut heap = PriorityQueue::from_vec(vec!(2, 4, 9));
269252
assert_eq!(heap.len(), 3);
270-
assert!(*heap.top().unwrap() == 9);
253+
assert!(*heap.top() == 9);
271254
heap.push(11);
272255
assert_eq!(heap.len(), 4);
273-
assert!(*heap.top().unwrap() == 11);
256+
assert!(*heap.top() == 11);
274257
heap.push(5);
275258
assert_eq!(heap.len(), 5);
276-
assert!(*heap.top().unwrap() == 11);
259+
assert!(*heap.top() == 11);
277260
heap.push(27);
278261
assert_eq!(heap.len(), 6);
279-
assert!(*heap.top().unwrap() == 27);
262+
assert!(*heap.top() == 27);
280263
heap.push(3);
281264
assert_eq!(heap.len(), 7);
282-
assert!(*heap.top().unwrap() == 27);
265+
assert!(*heap.top() == 27);
283266
heap.push(103);
284267
assert_eq!(heap.len(), 8);
285-
assert!(*heap.top().unwrap() == 103);
268+
assert!(*heap.top() == 103);
286269
}
287270

288271
#[test]
289272
fn test_push_unique() {
290273
let mut heap = PriorityQueue::from_vec(vec!(box 2, box 4, box 9));
291274
assert_eq!(heap.len(), 3);
292-
assert!(*heap.top().unwrap() == box 9);
275+
assert!(*heap.top() == box 9);
293276
heap.push(box 11);
294277
assert_eq!(heap.len(), 4);
295-
assert!(*heap.top().unwrap() == box 11);
278+
assert!(*heap.top() == box 11);
296279
heap.push(box 5);
297280
assert_eq!(heap.len(), 5);
298-
assert!(*heap.top().unwrap() == box 11);
281+
assert!(*heap.top() == box 11);
299282
heap.push(box 27);
300283
assert_eq!(heap.len(), 6);
301-
assert!(*heap.top().unwrap() == box 27);
284+
assert!(*heap.top() == box 27);
302285
heap.push(box 3);
303286
assert_eq!(heap.len(), 7);
304-
assert!(*heap.top().unwrap() == box 27);
287+
assert!(*heap.top() == box 27);
305288
heap.push(box 103);
306289
assert_eq!(heap.len(), 8);
307-
assert!(*heap.top().unwrap() == box 103);
290+
assert!(*heap.top() == box 103);
308291
}
309292

310293
#[test]
@@ -325,24 +308,24 @@ mod tests {
325308
fn test_replace() {
326309
let mut heap = PriorityQueue::from_vec(vec!(5, 5, 2, 1, 3));
327310
assert_eq!(heap.len(), 5);
328-
assert_eq!(heap.replace(6).unwrap(), 5);
311+
assert_eq!(heap.replace(6), 5);
329312
assert_eq!(heap.len(), 5);
330-
assert_eq!(heap.replace(0).unwrap(), 6);
313+
assert_eq!(heap.replace(0), 6);
331314
assert_eq!(heap.len(), 5);
332-
assert_eq!(heap.replace(4).unwrap(), 5);
315+
assert_eq!(heap.replace(4), 5);
333316
assert_eq!(heap.len(), 5);
334-
assert_eq!(heap.replace(1).unwrap(), 4);
317+
assert_eq!(heap.replace(1), 4);
335318
assert_eq!(heap.len(), 5);
336319
}
337320

338321
fn check_to_vec(mut data: Vec<int>) {
339322
let heap = PriorityQueue::from_vec(data.clone());
340-
let mut v = heap.clone().into_vec();
323+
let mut v = heap.clone().to_vec();
341324
v.sort();
342325
data.sort();
343326

344327
assert_eq!(v, data);
345-
assert_eq!(heap.into_sorted_vec(), data);
328+
assert_eq!(heap.to_sorted_vec(), data);
346329
}
347330

348331
#[test]
@@ -363,21 +346,36 @@ mod tests {
363346
}
364347

365348
#[test]
349+
#[should_fail]
366350
fn test_empty_pop() {
367351
let mut heap: PriorityQueue<int> = PriorityQueue::new();
368-
assert!(heap.pop().is_none());
352+
heap.pop();
353+
}
354+
355+
#[test]
356+
fn test_empty_maybe_pop() {
357+
let mut heap: PriorityQueue<int> = PriorityQueue::new();
358+
assert!(heap.maybe_pop().is_none());
369359
}
370360

371361
#[test]
362+
#[should_fail]
372363
fn test_empty_top() {
373364
let empty: PriorityQueue<int> = PriorityQueue::new();
374-
assert!(empty.top().is_none());
365+
empty.top();
366+
}
367+
368+
#[test]
369+
fn test_empty_maybe_top() {
370+
let empty: PriorityQueue<int> = PriorityQueue::new();
371+
assert!(empty.maybe_top().is_none());
375372
}
376373

377374
#[test]
375+
#[should_fail]
378376
fn test_empty_replace() {
379377
let mut heap: PriorityQueue<int> = PriorityQueue::new();
380-
heap.replace(5).is_none();
378+
heap.replace(5);
381379
}
382380

383381
#[test]
@@ -387,7 +385,7 @@ mod tests {
387385
let mut q: PriorityQueue<uint> = xs.as_slice().iter().rev().map(|&x| x).collect();
388386

389387
for &x in xs.iter() {
390-
assert_eq!(q.pop().unwrap(), x);
388+
assert_eq!(q.pop(), x);
391389
}
392390
}
393391
}

trunk/src/libcore/bool.rs

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -15,14 +15,11 @@
1515
//! Implementations of the following traits:
1616
//!
1717
//! * `Not`
18-
//! * `BitAnd`
19-
//! * `BitOr`
20-
//! * `BitXor`
2118
//! * `Ord`
2219
//! * `TotalOrd`
2320
//! * `Eq`
24-
//! * `TotalEq`
2521
//! * `Default`
22+
//! * `Zero`
2623
//!
2724
//! A `to_bit` conversion function.
2825

trunk/src/libcore/lib.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@
1717
//!
1818
//! * `memcpy`, `memcmp`, `memset` - These are core memory routines which are
1919
//! often generated by LLVM. Additionally, this library can make explicit
20-
//! calls to these funcitons. Their signatures are the same as found in C.
20+
//! calls to these functions. Their signatures are the same as found in C.
2121
//! These functions are often provided by the system libc, but can also be
2222
//! provided by `librlibc` which is distributed with the standard rust
2323
//! distribution.

0 commit comments

Comments
 (0)