Skip to content

Commit c159acb

Browse files
committed
auto merge of #10568 : pcwalton/rust/more-bars, r=alexcrichton
r? @alexcrichton
2 parents eef913b + 7e3f201 commit c159acb

Some content is hidden

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

141 files changed

+931
-871
lines changed

src/libextra/arc.rs

+11-13
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@ impl<T:Send> MutexArc<T> {
220220
* blocked on the mutex) will also fail immediately.
221221
*/
222222
#[inline]
223-
pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
223+
pub unsafe fn unsafe_access<U>(&self, blk: |x: &mut T| -> U) -> U {
224224
let state = self.x.get();
225225
// Borrowck would complain about this if the function were
226226
// not already unsafe. See borrow_rwlock, far below.
@@ -234,8 +234,7 @@ impl<T:Send> MutexArc<T> {
234234
/// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
235235
#[inline]
236236
pub unsafe fn unsafe_access_cond<U>(&self,
237-
blk: &fn(x: &mut T,
238-
c: &Condvar) -> U)
237+
blk: |x: &mut T, c: &Condvar| -> U)
239238
-> U {
240239
let state = self.x.get();
241240
do (&(*state).lock).lock_cond |cond| {
@@ -284,15 +283,14 @@ impl<T:Freeze + Send> MutexArc<T> {
284283
* unsafe_access_cond.
285284
*/
286285
#[inline]
287-
pub fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
286+
pub fn access<U>(&self, blk: |x: &mut T| -> U) -> U {
288287
unsafe { self.unsafe_access(blk) }
289288
}
290289

291290
/// As unsafe_access_cond but safe and Freeze.
292291
#[inline]
293292
pub fn access_cond<U>(&self,
294-
blk: &fn(x: &mut T,
295-
c: &Condvar) -> U)
293+
blk: |x: &mut T, c: &Condvar| -> U)
296294
-> U {
297295
unsafe { self.unsafe_access_cond(blk) }
298296
}
@@ -389,7 +387,7 @@ impl<T:Freeze + Send> RWArc<T> {
389387
* poison the Arc, so subsequent readers and writers will both also fail.
390388
*/
391389
#[inline]
392-
pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
390+
pub fn write<U>(&self, blk: |x: &mut T| -> U) -> U {
393391
unsafe {
394392
let state = self.x.get();
395393
do (*borrow_rwlock(state)).write {
@@ -403,7 +401,7 @@ impl<T:Freeze + Send> RWArc<T> {
403401
/// As write(), but with a condvar, as sync::rwlock.write_cond().
404402
#[inline]
405403
pub fn write_cond<U>(&self,
406-
blk: &fn(x: &mut T, c: &Condvar) -> U)
404+
blk: |x: &mut T, c: &Condvar| -> U)
407405
-> U {
408406
unsafe {
409407
let state = self.x.get();
@@ -427,7 +425,7 @@ impl<T:Freeze + Send> RWArc<T> {
427425
* Failing will unlock the Arc while unwinding. However, unlike all other
428426
* access modes, this will not poison the Arc.
429427
*/
430-
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
428+
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
431429
unsafe {
432430
let state = self.x.get();
433431
do (*state).lock.read {
@@ -457,7 +455,7 @@ impl<T:Freeze + Send> RWArc<T> {
457455
* }
458456
* ```
459457
*/
460-
pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
458+
pub fn write_downgrade<U>(&self, blk: |v: RWWriteMode<T>| -> U) -> U {
461459
unsafe {
462460
let state = self.x.get();
463461
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
@@ -539,7 +537,7 @@ pub struct RWReadMode<'self, T> {
539537

540538
impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
541539
/// Access the pre-downgrade RWArc in write mode.
542-
pub fn write<U>(&mut self, blk: &fn(x: &mut T) -> U) -> U {
540+
pub fn write<U>(&mut self, blk: |x: &mut T| -> U) -> U {
543541
match *self {
544542
RWWriteMode {
545543
data: &ref mut data,
@@ -555,7 +553,7 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
555553

556554
/// Access the pre-downgrade RWArc in write mode with a condvar.
557555
pub fn write_cond<U>(&mut self,
558-
blk: &fn(x: &mut T, c: &Condvar) -> U)
556+
blk: |x: &mut T, c: &Condvar| -> U)
559557
-> U {
560558
match *self {
561559
RWWriteMode {
@@ -580,7 +578,7 @@ impl<'self, T:Freeze + Send> RWWriteMode<'self, T> {
580578

581579
impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
582580
/// Access the post-downgrade rwlock in read mode.
583-
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
581+
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
584582
match *self {
585583
RWReadMode {
586584
data: data,

src/libextra/arena.rs

+3-3
Original file line numberDiff line numberDiff line change
@@ -184,7 +184,7 @@ impl Arena {
184184
}
185185

186186
#[inline]
187-
fn alloc_pod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
187+
fn alloc_pod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
188188
unsafe {
189189
let tydesc = get_tydesc::<T>();
190190
let ptr = self.alloc_pod_inner((*tydesc).size, (*tydesc).align);
@@ -241,7 +241,7 @@ impl Arena {
241241
}
242242

243243
#[inline]
244-
fn alloc_nonpod<'a, T>(&'a mut self, op: &fn() -> T) -> &'a T {
244+
fn alloc_nonpod<'a, T>(&'a mut self, op: || -> T) -> &'a T {
245245
unsafe {
246246
let tydesc = get_tydesc::<T>();
247247
let (ty_ptr, ptr) =
@@ -263,7 +263,7 @@ impl Arena {
263263

264264
// The external interface
265265
#[inline]
266-
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
266+
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
267267
unsafe {
268268
// XXX: Borrow check
269269
let this = transmute_mut(self);

src/libextra/bitv.rs

+12-12
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ impl SmallBitv {
4040
pub fn bits_op(&mut self,
4141
right_bits: uint,
4242
nbits: uint,
43-
f: &fn(uint, uint) -> uint)
43+
f: |uint, uint| -> uint)
4444
-> bool {
4545
let mask = small_mask(nbits);
4646
let old_b: uint = self.bits;
@@ -140,7 +140,7 @@ impl BigBitv {
140140
pub fn process(&mut self,
141141
b: &BigBitv,
142142
nbits: uint,
143-
op: &fn(uint, uint) -> uint)
143+
op: |uint, uint| -> uint)
144144
-> bool {
145145
let len = b.storage.len();
146146
assert_eq!(self.storage.len(), len);
@@ -161,7 +161,7 @@ impl BigBitv {
161161
}
162162

163163
#[inline]
164-
pub fn each_storage(&mut self, op: &fn(v: &mut uint) -> bool) -> bool {
164+
pub fn each_storage(&mut self, op: |v: &mut uint| -> bool) -> bool {
165165
self.storage.mut_iter().advance(|elt| op(elt))
166166
}
167167

@@ -512,7 +512,7 @@ impl Bitv {
512512
true
513513
}
514514

515-
pub fn ones(&self, f: &fn(uint) -> bool) -> bool {
515+
pub fn ones(&self, f: |uint| -> bool) -> bool {
516516
range(0u, self.nbits).advance(|i| !self.get(i) || f(i))
517517
}
518518

@@ -542,7 +542,7 @@ pub fn from_bools(bools: &[bool]) -> Bitv {
542542
* Create a `Bitv` of the specified length where the value at each
543543
* index is `f(index)`.
544544
*/
545-
pub fn from_fn(len: uint, f: &fn(index: uint) -> bool) -> Bitv {
545+
pub fn from_fn(len: uint, f: |index: uint| -> bool) -> Bitv {
546546
let mut bitv = Bitv::new(len, false);
547547
for i in range(0u, len) {
548548
bitv.set(i, f(i));
@@ -557,7 +557,7 @@ impl ops::Index<uint,bool> for Bitv {
557557
}
558558

559559
#[inline]
560-
fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
560+
fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
561561
if bits == 0 {
562562
return true;
563563
}
@@ -675,7 +675,7 @@ impl BitvSet {
675675
}
676676

677677
#[inline]
678-
fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
678+
fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
679679
fn nbits(mut w: uint) -> uint {
680680
let mut bits = 0;
681681
for _ in range(0u, uint::bits) {
@@ -722,7 +722,7 @@ impl BitvSet {
722722
BitvSetIterator {set: self, next_idx: 0}
723723
}
724724

725-
pub fn difference(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
725+
pub fn difference(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
726726
for (i, w1, w2) in self.common_iter(other) {
727727
if !iterate_bits(i, w1 & !w2, |b| f(&b)) {
728728
return false
@@ -734,8 +734,8 @@ impl BitvSet {
734734
)
735735
}
736736

737-
pub fn symmetric_difference(&self, other: &BitvSet,
738-
f: &fn(&uint) -> bool) -> bool {
737+
pub fn symmetric_difference(&self, other: &BitvSet, f: |&uint| -> bool)
738+
-> bool {
739739
for (i, w1, w2) in self.common_iter(other) {
740740
if !iterate_bits(i, w1 ^ w2, |b| f(&b)) {
741741
return false
@@ -744,11 +744,11 @@ impl BitvSet {
744744
self.outlier_iter(other).advance(|(_, i, w)| iterate_bits(i, w, |b| f(&b)))
745745
}
746746

747-
pub fn intersection(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
747+
pub fn intersection(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
748748
self.common_iter(other).advance(|(i, w1, w2)| iterate_bits(i, w1 & w2, |b| f(&b)))
749749
}
750750

751-
pub fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
751+
pub fn union(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
752752
for (i, w1, w2) in self.common_iter(other) {
753753
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
754754
return false

src/libextra/dlist.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -320,7 +320,7 @@ impl<T> DList<T> {
320320
/// or at the end.
321321
///
322322
/// O(N)
323-
pub fn insert_when(&mut self, elt: T, f: &fn(&T, &T) -> bool) {
323+
pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) {
324324
{
325325
let mut it = self.mut_iter();
326326
loop {
@@ -339,7 +339,7 @@ impl<T> DList<T> {
339339
/// put `a` in the result if `f(a, b)` is true, else `b`.
340340
///
341341
/// O(max(N, M))
342-
pub fn merge(&mut self, mut other: DList<T>, f: &fn(&T, &T) -> bool) {
342+
pub fn merge(&mut self, mut other: DList<T>, f: |&T, &T| -> bool) {
343343
{
344344
let mut it = self.mut_iter();
345345
loop {

0 commit comments

Comments
 (0)