Skip to content

More bars #10568

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Nov 19, 2013
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 11 additions & 13 deletions src/libextra/arc.rs
Original file line number Diff line number Diff line change
Expand Up @@ -220,7 +220,7 @@ impl<T:Send> MutexArc<T> {
* blocked on the mutex) will also fail immediately.
*/
#[inline]
pub unsafe fn unsafe_access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
pub unsafe fn unsafe_access<U>(&self, blk: |x: &mut T| -> U) -> U {
let state = self.x.get();
// Borrowck would complain about this if the function were
// not already unsafe. See borrow_rwlock, far below.
Expand All @@ -234,8 +234,7 @@ impl<T:Send> MutexArc<T> {
/// As unsafe_access(), but with a condvar, as sync::mutex.lock_cond().
#[inline]
pub unsafe fn unsafe_access_cond<U>(&self,
blk: &fn(x: &mut T,
c: &Condvar) -> U)
blk: |x: &mut T, c: &Condvar| -> U)
-> U {
let state = self.x.get();
do (&(*state).lock).lock_cond |cond| {
Expand Down Expand Up @@ -284,15 +283,14 @@ impl<T:Freeze + Send> MutexArc<T> {
* unsafe_access_cond.
*/
#[inline]
pub fn access<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
pub fn access<U>(&self, blk: |x: &mut T| -> U) -> U {
unsafe { self.unsafe_access(blk) }
}

/// As unsafe_access_cond but safe and Freeze.
#[inline]
pub fn access_cond<U>(&self,
blk: &fn(x: &mut T,
c: &Condvar) -> U)
blk: |x: &mut T, c: &Condvar| -> U)
-> U {
unsafe { self.unsafe_access_cond(blk) }
}
Expand Down Expand Up @@ -389,7 +387,7 @@ impl<T:Freeze + Send> RWArc<T> {
* poison the Arc, so subsequent readers and writers will both also fail.
*/
#[inline]
pub fn write<U>(&self, blk: &fn(x: &mut T) -> U) -> U {
pub fn write<U>(&self, blk: |x: &mut T| -> U) -> U {
unsafe {
let state = self.x.get();
do (*borrow_rwlock(state)).write {
Expand All @@ -403,7 +401,7 @@ impl<T:Freeze + Send> RWArc<T> {
/// As write(), but with a condvar, as sync::rwlock.write_cond().
#[inline]
pub fn write_cond<U>(&self,
blk: &fn(x: &mut T, c: &Condvar) -> U)
blk: |x: &mut T, c: &Condvar| -> U)
-> U {
unsafe {
let state = self.x.get();
Expand All @@ -427,7 +425,7 @@ impl<T:Freeze + Send> RWArc<T> {
* Failing will unlock the Arc while unwinding. However, unlike all other
* access modes, this will not poison the Arc.
*/
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
unsafe {
let state = self.x.get();
do (*state).lock.read {
Expand Down Expand Up @@ -457,7 +455,7 @@ impl<T:Freeze + Send> RWArc<T> {
* }
* ```
*/
pub fn write_downgrade<U>(&self, blk: &fn(v: RWWriteMode<T>) -> U) -> U {
pub fn write_downgrade<U>(&self, blk: |v: RWWriteMode<T>| -> U) -> U {
unsafe {
let state = self.x.get();
do (*borrow_rwlock(state)).write_downgrade |write_mode| {
Expand Down Expand Up @@ -539,7 +537,7 @@ pub struct RWReadMode<'self, T> {

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

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

impl<'self, T:Freeze + Send> RWReadMode<'self, T> {
/// Access the post-downgrade rwlock in read mode.
pub fn read<U>(&self, blk: &fn(x: &T) -> U) -> U {
pub fn read<U>(&self, blk: |x: &T| -> U) -> U {
match *self {
RWReadMode {
data: data,
Expand Down
6 changes: 3 additions & 3 deletions src/libextra/arena.rs
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ impl Arena {
}

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

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

// The external interface
#[inline]
pub fn alloc<'a, T>(&'a self, op: &fn() -> T) -> &'a T {
pub fn alloc<'a, T>(&'a self, op: || -> T) -> &'a T {
unsafe {
// XXX: Borrow check
let this = transmute_mut(self);
Expand Down
24 changes: 12 additions & 12 deletions src/libextra/bitv.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ impl SmallBitv {
pub fn bits_op(&mut self,
right_bits: uint,
nbits: uint,
f: &fn(uint, uint) -> uint)
f: |uint, uint| -> uint)
-> bool {
let mask = small_mask(nbits);
let old_b: uint = self.bits;
Expand Down Expand Up @@ -140,7 +140,7 @@ impl BigBitv {
pub fn process(&mut self,
b: &BigBitv,
nbits: uint,
op: &fn(uint, uint) -> uint)
op: |uint, uint| -> uint)
-> bool {
let len = b.storage.len();
assert_eq!(self.storage.len(), len);
Expand All @@ -161,7 +161,7 @@ impl BigBitv {
}

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

Expand Down Expand Up @@ -512,7 +512,7 @@ impl Bitv {
true
}

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

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

#[inline]
fn iterate_bits(base: uint, bits: uint, f: &fn(uint) -> bool) -> bool {
fn iterate_bits(base: uint, bits: uint, f: |uint| -> bool) -> bool {
if bits == 0 {
return true;
}
Expand Down Expand Up @@ -675,7 +675,7 @@ impl BitvSet {
}

#[inline]
fn other_op(&mut self, other: &BitvSet, f: &fn(uint, uint) -> uint) {
fn other_op(&mut self, other: &BitvSet, f: |uint, uint| -> uint) {
fn nbits(mut w: uint) -> uint {
let mut bits = 0;
for _ in range(0u, uint::bits) {
Expand Down Expand Up @@ -722,7 +722,7 @@ impl BitvSet {
BitvSetIterator {set: self, next_idx: 0}
}

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

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

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

pub fn union(&self, other: &BitvSet, f: &fn(&uint) -> bool) -> bool {
pub fn union(&self, other: &BitvSet, f: |&uint| -> bool) -> bool {
for (i, w1, w2) in self.common_iter(other) {
if !iterate_bits(i, w1 | w2, |b| f(&b)) {
return false
Expand Down
4 changes: 2 additions & 2 deletions src/libextra/dlist.rs
Original file line number Diff line number Diff line change
Expand Up @@ -320,7 +320,7 @@ impl<T> DList<T> {
/// or at the end.
///
/// O(N)
pub fn insert_when(&mut self, elt: T, f: &fn(&T, &T) -> bool) {
pub fn insert_when(&mut self, elt: T, f: |&T, &T| -> bool) {
{
let mut it = self.mut_iter();
loop {
Expand All @@ -339,7 +339,7 @@ impl<T> DList<T> {
/// put `a` in the result if `f(a, b)` is true, else `b`.
///
/// O(max(N, M))
pub fn merge(&mut self, mut other: DList<T>, f: &fn(&T, &T) -> bool) {
pub fn merge(&mut self, mut other: DList<T>, f: |&T, &T| -> bool) {
{
let mut it = self.mut_iter();
loop {
Expand Down
Loading