Skip to content

Commit 29bf1e9

Browse files
committed
---
yaml --- r: 50560 b: refs/heads/try c: 80c71c8 h: refs/heads/master v: v3
1 parent bbb38c7 commit 29bf1e9

38 files changed

+675
-544
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
refs/heads/master: 5f13e9ccc2e3328d4cd8ca49f84e6840dd998346
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
44
refs/heads/snap-stage3: f7a2371c176663d59062ec5158f39faecba45768
5-
refs/heads/try: 267f6c212f471c100060edaaf85a26e9a7ba820f
5+
refs/heads/try: 80c71c839acde882e53ee9505a05b81e4af33ab7
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: 147ecfdd8221e4a4d4e090486829a06da1e0ca3c

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

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77

88
(require 'cm-mode)
99
(require 'cc-mode)
10-
(eval-when-compile (require 'cl))
1110

1211
(defun rust-electric-brace (arg)
1312
(interactive "*P")

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
</list>
1818
<list name="keywords">
1919
<item> as </item>
20+
<item> assert </item>
2021
<item> break </item>
2122
<item> const </item>
2223
<item> copy </item>
@@ -68,7 +69,6 @@
6869
<item> Shl </item>
6970
<item> Shr </item>
7071
<item> Index </item>
71-
<item> Not </item>
7272
</list>
7373
<list name="types">
7474
<item> bool </item>

branches/try/src/libcore/clone.rs

Lines changed: 0 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -19,31 +19,3 @@ impl Clone for () {
1919
#[inline(always)]
2020
fn clone(&self) -> () { () }
2121
}
22-
23-
macro_rules! clone_impl(
24-
($t:ty) => {
25-
impl Clone for $t {
26-
#[inline(always)]
27-
fn clone(&self) -> $t { *self }
28-
}
29-
}
30-
)
31-
32-
clone_impl!(int)
33-
clone_impl!(i8)
34-
clone_impl!(i16)
35-
clone_impl!(i32)
36-
clone_impl!(i64)
37-
38-
clone_impl!(uint)
39-
clone_impl!(u8)
40-
clone_impl!(u16)
41-
clone_impl!(u32)
42-
clone_impl!(u64)
43-
44-
clone_impl!(float)
45-
clone_impl!(f32)
46-
clone_impl!(f64)
47-
48-
clone_impl!(bool)
49-
clone_impl!(char)

branches/try/src/libcore/core.rc

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,6 @@ Implicitly, all crates behave as if they included the following prologue:
5151
#[warn(vecs_implicitly_copyable)];
5252
#[deny(non_camel_case_types)];
5353
#[allow(deprecated_mutable_fields)];
54-
#[deny(deprecated_self)];
5554

5655
// On Linux, link to the runtime with -lrt.
5756
#[cfg(target_os = "linux")]
@@ -143,6 +142,8 @@ pub mod option;
143142
pub mod result;
144143
pub mod either;
145144
pub mod dlist;
145+
#[path="iter-trait.rs"] #[merge = "iter-trait/dlist.rs"]
146+
pub mod dlist_iter;
146147
pub mod hashmap;
147148
pub mod cell;
148149
pub mod trie;

branches/try/src/libcore/dlist.rs

Lines changed: 1 addition & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,6 @@ Do not use ==, !=, <, etc on doubly-linked lists -- it may not terminate.
1818
1919
*/
2020

21-
use iter;
22-
use iter::BaseIter;
2321
use kinds::Copy;
2422
use managed;
2523
use option::{None, Option, Some};
@@ -491,54 +489,14 @@ pub impl<T:Copy> DList<T> {
491489
let mut v = vec::with_capacity(self.size);
492490
unsafe {
493491
// Take this out of the unchecked when iter's functions are pure
494-
for iter::eachi(&self) |index,data| {
492+
for self.eachi |index,data| {
495493
v[index] = *data;
496494
}
497495
}
498496
v
499497
}
500498
}
501499

502-
impl<T> BaseIter<T> for @mut DList<T> {
503-
/**
504-
* Iterates through the current contents.
505-
*
506-
* Attempts to access this dlist during iteration are allowed (to
507-
* allow for e.g. breadth-first search with in-place enqueues), but
508-
* removing the current node is forbidden.
509-
*/
510-
pure fn each(&self, f: fn(v: &T) -> bool) {
511-
let mut link = self.peek_n();
512-
while option::is_some(&link) {
513-
let nobe = option::get(link);
514-
fail_unless!(nobe.linked);
515-
516-
{
517-
let frozen_nobe = &*nobe;
518-
if !f(&frozen_nobe.data) { break; }
519-
}
520-
521-
// Check (weakly) that the user didn't do a remove.
522-
if self.size == 0 {
523-
fail!(~"The dlist became empty during iteration??")
524-
}
525-
if !nobe.linked ||
526-
(!((nobe.prev.is_some()
527-
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
528-
nobe))
529-
&& (nobe.next.is_some()
530-
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
531-
nobe)))) {
532-
fail!(~"Removing a dlist node during iteration is forbidden!")
533-
}
534-
link = nobe.next_link();
535-
}
536-
}
537-
538-
#[inline(always)]
539-
pure fn size_hint(&self) -> Option<uint> { Some(self.len()) }
540-
}
541-
542500
#[cfg(test)]
543501
mod tests {
544502
use dlist::{DList, concat, from_vec, new_dlist_node};
Lines changed: 89 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,89 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
// This makes use of a clever hack that brson came up with to
12+
// workaround our lack of traits and lack of macros. See core.{rc,rs} for
13+
// how this file is used.
14+
15+
use cmp::{Eq, Ord};
16+
use iter::BaseIter;
17+
use iter;
18+
use kinds::Copy;
19+
use option::Option;
20+
21+
use self::inst::{IMPL_T, EACH, SIZE_HINT};
22+
23+
impl<A> iter::BaseIter<A> for IMPL_T<A> {
24+
#[inline(always)]
25+
pure fn each(&self, blk: fn(v: &A) -> bool) { EACH(self, blk) }
26+
#[inline(always)]
27+
pure fn size_hint(&self) -> Option<uint> { SIZE_HINT(self) }
28+
}
29+
30+
impl<A> iter::ExtendedIter<A> for IMPL_T<A> {
31+
#[inline(always)]
32+
pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) {
33+
iter::eachi(self, blk)
34+
}
35+
#[inline(always)]
36+
pure fn all(&self, blk: fn(&A) -> bool) -> bool {
37+
iter::all(self, blk)
38+
}
39+
#[inline(always)]
40+
pure fn any(&self, blk: fn(&A) -> bool) -> bool {
41+
iter::any(self, blk)
42+
}
43+
#[inline(always)]
44+
pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B {
45+
iter::foldl(self, b0, blk)
46+
}
47+
#[inline(always)]
48+
pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> {
49+
iter::position(self, f)
50+
}
51+
#[inline(always)]
52+
pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] {
53+
iter::map_to_vec(self, op)
54+
}
55+
#[inline(always)]
56+
pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB)
57+
-> ~[B] {
58+
iter::flat_map_to_vec(self, op)
59+
}
60+
61+
}
62+
63+
impl<A:Eq> iter::EqIter<A> for IMPL_T<A> {
64+
#[inline(always)]
65+
pure fn contains(&self, x: &A) -> bool { iter::contains(self, x) }
66+
#[inline(always)]
67+
pure fn count(&self, x: &A) -> uint { iter::count(self, x) }
68+
}
69+
70+
impl<A:Copy> iter::CopyableIter<A> for IMPL_T<A> {
71+
#[inline(always)]
72+
pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] {
73+
iter::filter_to_vec(self, pred)
74+
}
75+
#[inline(always)]
76+
pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) }
77+
#[inline(always)]
78+
pure fn find(&self, f: fn(&A) -> bool) -> Option<A> {
79+
iter::find(self, f)
80+
}
81+
}
82+
83+
impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for IMPL_T<A> {
84+
#[inline(always)]
85+
pure fn min(&self) -> A { iter::min(self) }
86+
#[inline(always)]
87+
pure fn max(&self) -> A { iter::max(self) }
88+
}
89+
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
// Copyright 2012 The Rust Project Developers. See the COPYRIGHT
2+
// file at the top-level directory of this distribution and at
3+
// http://rust-lang.org/COPYRIGHT.
4+
//
5+
// Licensed under the Apache License, Version 2.0 <LICENSE-APACHE or
6+
// http://www.apache.org/licenses/LICENSE-2.0> or the MIT license
7+
// <LICENSE-MIT or http://opensource.org/licenses/MIT>, at your
8+
// option. This file may not be copied, modified, or distributed
9+
// except according to those terms.
10+
11+
mod inst {
12+
use dlist::DList;
13+
use managed;
14+
use option::{Option, Some};
15+
use option;
16+
17+
#[allow(non_camel_case_types)]
18+
pub type IMPL_T<A> = @mut DList<A>;
19+
20+
/**
21+
* Iterates through the current contents.
22+
*
23+
* Attempts to access this dlist during iteration are allowed (to
24+
* allow for e.g. breadth-first search with in-place enqueues), but
25+
* removing the current node is forbidden.
26+
*/
27+
pub pure fn EACH<A>(self: &IMPL_T<A>, f: fn(v: &A) -> bool) {
28+
let mut link = self.peek_n();
29+
while option::is_some(&link) {
30+
let nobe = option::get(link);
31+
fail_unless!(nobe.linked);
32+
33+
{
34+
let frozen_nobe = &*nobe;
35+
if !f(&frozen_nobe.data) { break; }
36+
}
37+
38+
// Check (weakly) that the user didn't do a remove.
39+
if self.size == 0 {
40+
fail!(~"The dlist became empty during iteration??")
41+
}
42+
if !nobe.linked ||
43+
(!((nobe.prev.is_some()
44+
|| managed::mut_ptr_eq(self.hd.expect(~"headless dlist?"),
45+
nobe))
46+
&& (nobe.next.is_some()
47+
|| managed::mut_ptr_eq(self.tl.expect(~"tailless dlist?"),
48+
nobe)))) {
49+
fail!(~"Removing a dlist node during iteration is forbidden!")
50+
}
51+
link = nobe.next_link();
52+
}
53+
}
54+
55+
#[inline(always)]
56+
pub pure fn SIZE_HINT<A>(self: &IMPL_T<A>) -> Option<uint> {
57+
Some(self.len())
58+
}
59+
}

branches/try/src/libcore/nil.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ Functions for the unit type.
1515
*/
1616

1717
#[cfg(notest)]
18-
use cmp::{Eq, Ord};
18+
use cmp::{Eq, Ord, TotalOrd, Ordering, Equal};
1919

2020
#[cfg(notest)]
2121
impl Eq for () {
@@ -37,3 +37,8 @@ impl Ord for () {
3737
pure fn gt(&self, _other: &()) -> bool { false }
3838
}
3939

40+
#[cfg(notest)]
41+
impl TotalOrd for () {
42+
#[inline(always)]
43+
pure fn cmp(&self, _other: &()) -> Ordering { Equal }
44+
}

0 commit comments

Comments
 (0)