Skip to content

Commit a9cd712

Browse files
committed
---
yaml --- r: 21238 b: refs/heads/snap-stage3 c: 8ee79c7 h: refs/heads/master v: v3
1 parent 1b9c0c0 commit a9cd712

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

51 files changed

+3869
-2566
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: e430a699f2c60890d9b86069fd0c68a70ece7120
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: 3b09c3deaa9a376d0ae40a783713ece3720ca08f
4+
refs/heads/snap-stage3: 8ee79c79aada1b5943b5ada11570f9b903c74579
55
refs/heads/try: ffbe0e0e00374358b789b0037bcb3a577cd218be
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

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

Lines changed: 27 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ priv impl<A> DVec<A> {
9090
}
9191

9292
#[inline(always)]
93-
fn borrow<B>(f: fn(-~[mut A]) -> B) -> B {
93+
fn check_out<B>(f: fn(-~[mut A]) -> B) -> B {
9494
unsafe {
9595
let mut data = unsafe::reinterpret_cast(null::<()>());
9696
data <-> self.data;
@@ -124,13 +124,13 @@ impl<A> DVec<A> {
124124
*/
125125
#[inline(always)]
126126
fn swap(f: fn(-~[mut A]) -> ~[mut A]) {
127-
self.borrow(|v| self.give_back(f(v)))
127+
self.check_out(|v| self.give_back(f(v)))
128128
}
129129

130130
/// Returns the number of elements currently in the dvec
131131
pure fn len() -> uint {
132132
unchecked {
133-
do self.borrow |v| {
133+
do self.check_out |v| {
134134
let l = v.len();
135135
self.give_back(v);
136136
l
@@ -146,7 +146,7 @@ impl<A> DVec<A> {
146146

147147
/// Remove and return the last element
148148
fn pop() -> A {
149-
do self.borrow |v| {
149+
do self.check_out |v| {
150150
let mut v <- v;
151151
let result = vec::pop(v);
152152
self.give_back(v);
@@ -176,18 +176,37 @@ impl<A> DVec<A> {
176176
177177
/// Remove and return the first element
178178
fn shift() -> A {
179-
do self.borrow |v| {
179+
do self.check_out |v| {
180180
let mut v = vec::from_mut(v);
181181
let result = vec::shift(v);
182182
self.give_back(vec::to_mut(v));
183183
result
184184
}
185185
}
186186
187-
// Reverse the elements in the list, in place
187+
/// Reverse the elements in the list, in place
188188
fn reverse() {
189-
do self.borrow |v| {
189+
do self.check_out |v| {
190190
vec::reverse(v);
191+
self.give_back(v);
192+
}
193+
}
194+
195+
/// Gives access to the vector as a slice with immutable contents
196+
fn borrow<R>(op: fn(x: &[A]) -> R) -> R {
197+
do self.check_out |v| {
198+
let result = op(v);
199+
self.give_back(v);
200+
result
201+
}
202+
}
203+
204+
/// Gives access to the vector as a slice with mutable contents
205+
fn borrow_mut<R>(op: fn(x: &[mut A]) -> R) -> R {
206+
do self.check_out |v| {
207+
let result = op(v);
208+
self.give_back(v);
209+
result
191210
}
192211
}
193212
}
@@ -249,7 +268,7 @@ impl<A: copy> DVec<A> {
249268
*/
250269
pure fn get() -> ~[A] {
251270
unchecked {
252-
do self.borrow |v| {
271+
do self.check_out |v| {
253272
let w = vec::from_mut(copy v);
254273
self.give_back(v);
255274
w

branches/snap-stage3/src/libcore/task.rs

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1187,7 +1187,9 @@ fn spawn_raw(+opts: TaskOpts, +f: fn~()) {
11871187
};
11881188
if result {
11891189
// Unwinding function in case any ancestral enlisting fails
1190-
let bail = |tg| { leave_taskgroup(tg, child, false) };
1190+
let bail = |tg: TaskGroupInner| {
1191+
leave_taskgroup(tg, child, false)
1192+
};
11911193
// Attempt to join every ancestor group.
11921194
result =
11931195
for each_ancestor(ancestors, some(bail)) |ancestor_tg| {

branches/snap-stage3/src/libstd/cell.rs

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -41,10 +41,11 @@ impl<T> Cell<T> {
4141
}
4242

4343
// Calls a closure with a reference to the value.
44-
fn with_ref(f: fn(v: &T)) {
45-
let val = move self.take();
46-
f(&val);
47-
self.put_back(move val);
44+
fn with_ref<R>(op: fn(v: &T) -> R) -> R {
45+
let v = self.take();
46+
let r = op(&v);
47+
self.put_back(v);
48+
return move r;
4849
}
4950
}
5051

0 commit comments

Comments
 (0)