Skip to content

Commit 0bc8217

Browse files
committed
---
yaml --- r: 31467 b: refs/heads/dist-snap c: 01e2471 h: refs/heads/master i: 31465: ee0f84e 31463: e1c2030 v: v3
1 parent fa47abe commit 0bc8217

File tree

8 files changed

+56
-6
lines changed

8 files changed

+56
-6
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,6 @@ refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b
88
refs/heads/try2: d0c6ce338884ee21843f4b40bf6bf18d222ce5df
99
refs/heads/incoming: d9317a174e434d4c99fc1a37fd7dc0d2f5328d37
10-
refs/heads/dist-snap: b6aadf56c8a6e603c79a8924e6a92398471de8cf
10+
refs/heads/dist-snap: 01e2471cb7bc7f84863bdb0d67cfa2af16d54f9e
1111
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
1212
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503

branches/dist-snap/src/libcore/dvec.rs

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -310,3 +310,10 @@ impl extensions<A:copy> for dvec<A> {
310310
do self.swap |v| { vec::reachi(v, f); v }
311311
}
312312
}
313+
314+
impl extensions<A:copy> of ops::index<uint,A> for dvec<A> {
315+
pure fn index(&&idx: uint) -> A {
316+
self.get_elt(idx)
317+
}
318+
}
319+

branches/dist-snap/src/libcore/str.rs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1897,7 +1897,6 @@ trait unique_str {
18971897
fn trim() -> self;
18981898
fn trim_left() -> self;
18991899
fn trim_right() -> self;
1900-
pure fn +(rhs: &str) -> self;
19011900
}
19021901

19031902
/// Extension methods for strings
@@ -1919,6 +1918,13 @@ impl extensions of unique_str for ~str {
19191918
}
19201919
}
19211920

1921+
impl extensions of ops::add<&str,~str> for ~str {
1922+
#[inline(always)]
1923+
pure fn add(rhs: &str) -> ~str {
1924+
append(self, rhs)
1925+
}
1926+
}
1927+
19221928
trait str_slice {
19231929
fn all(it: fn(char) -> bool) -> bool;
19241930
fn any(it: fn(char) -> bool) -> bool;

branches/dist-snap/src/libcore/vec.rs

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1299,13 +1299,27 @@ impl extensions<T: copy> of vec_concat<T> for ~[T] {
12991299
}
13001300
}
13011301

1302+
impl extensions<T: copy> of ops::add<&[const T],~[T]> for ~[T] {
1303+
#[inline(always)]
1304+
pure fn add(rhs: &[const T]) -> ~[T] {
1305+
append(self, rhs)
1306+
}
1307+
}
1308+
13021309
impl extensions<T: copy> of vec_concat<T> for ~[mut T] {
13031310
#[inline(always)]
13041311
pure fn +(rhs: &[const T]) -> ~[mut T] {
13051312
append_mut(self, rhs)
13061313
}
13071314
}
13081315

1316+
impl extensions<T: copy> of ops::add<&[const T],~[mut T]> for ~[mut T] {
1317+
#[inline(always)]
1318+
pure fn add(rhs: &[const T]) -> ~[mut T] {
1319+
append_mut(self, rhs)
1320+
}
1321+
}
1322+
13091323
trait const_vector {
13101324
pure fn is_empty() -> bool;
13111325
pure fn is_not_empty() -> bool;

branches/dist-snap/src/libstd/bitv.rs

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -239,7 +239,7 @@ trait methods {
239239
fn union(rhs: bitv) -> bool;
240240
fn intersect(rhs: bitv) -> bool;
241241
fn assign(rhs: bitv) -> bool;
242-
fn get(i: uint) -> bool;
242+
pure fn get(i: uint) -> bool;
243243
fn [](i: uint) -> bool;
244244
fn eq(rhs: bitv) -> bool;
245245
fn clear();
@@ -261,7 +261,7 @@ impl of methods for bitv {
261261
fn union(rhs: bitv) -> bool { union(self, rhs) }
262262
fn intersect(rhs: bitv) -> bool { intersect(self, rhs) }
263263
fn assign(rhs: bitv) -> bool { assign(self, rhs) }
264-
fn get(i: uint) -> bool { get(self, i) }
264+
pure fn get(i: uint) -> bool { get(self, i) }
265265
fn [](i: uint) -> bool { self.get(i) }
266266
fn eq(rhs: bitv) -> bool { equal(self, rhs) }
267267
fn clear() { clear(self) }
@@ -285,6 +285,12 @@ impl of methods for bitv {
285285
}
286286
}
287287

288+
impl extensions of ops::index<uint,bool> for bitv {
289+
pure fn index(&&i: uint) -> bool {
290+
self.get(i)
291+
}
292+
}
293+
288294
impl of to_str::to_str for bitv {
289295
fn to_str() -> ~str { to_str(self) }
290296
}

branches/dist-snap/src/libstd/map.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,14 @@ mod chained {
314314
}
315315
}
316316

317+
impl hashmap<K, V: copy> of ops::index<K, V> for t<K, V> {
318+
pure fn index(k: K) -> V {
319+
unchecked {
320+
self.get(k)
321+
}
322+
}
323+
}
324+
317325

318326
fn chains<K,V>(nchains: uint) -> ~[mut chain<K,V>] {
319327
ret vec::to_mut(vec::from_elem(nchains, absent));

branches/dist-snap/src/libstd/smallintmap.rs

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ fn insert<T: copy>(self: smallintmap<T>, key: uint, val: T) {
3535
* Get the value for the specified key. If the key does not exist
3636
* in the map then returns none
3737
*/
38-
fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> {
38+
pure fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> {
3939
if key < self.v.len() { ret self.v.get_elt(key); }
4040
ret none::<T>;
4141
}
@@ -47,7 +47,7 @@ fn find<T: copy>(self: smallintmap<T>, key: uint) -> option<T> {
4747
*
4848
* If the key does not exist in the map
4949
*/
50-
fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
50+
pure fn get<T: copy>(self: smallintmap<T>, key: uint) -> T {
5151
alt find(self, key) {
5252
none { #error("smallintmap::get(): key not present"); fail; }
5353
some(v) { ret v; }
@@ -114,6 +114,14 @@ impl <V: copy> of map::map<uint, V> for smallintmap<V> {
114114
}
115115
}
116116

117+
impl extensions<V: copy> of ops::index<uint, V> for smallintmap<V> {
118+
pure fn index(&&key: uint) -> V {
119+
unchecked {
120+
get(self, key)
121+
}
122+
}
123+
}
124+
117125
/// Cast the given smallintmap to a map::map
118126
fn as_map<V: copy>(s: smallintmap<V>) -> map::map<uint, V> {
119127
s as map::map::<uint, V>

branches/dist-snap/src/rustc/middle/trans/shape.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ import syntax::util::interner;
1616
import util::ppaux::ty_to_str;
1717
import syntax::codemap::span;
1818
import dvec::{dvec, extensions};
19+
import vec::extensions;
1920

2021
import std::map::hashmap;
2122
import option::is_some;

0 commit comments

Comments
 (0)