Remove parentheses from closure argument types

This commit is contained in:
Erick Tryzelaar 2012-10-13 17:07:14 -07:00 committed by Graydon Hoare
parent 497a8b54b5
commit 9539724e8b
9 changed files with 26 additions and 26 deletions

View File

@ -13,8 +13,8 @@ pub enum Either<T, U> {
Right(U)
}
pub fn either<T, U, V>(f_left: fn((&T)) -> V,
f_right: fn((&U)) -> V, value: &Either<T, U>) -> V {
pub fn either<T, U, V>(f_left: fn(&T) -> V,
f_right: fn(&U) -> V, value: &Either<T, U>) -> V {
/*!
* Applies a function based on the given either value
*

View File

@ -489,11 +489,11 @@ pub fn tmpdir() -> Path {
}
}
/// Recursively walk a directory structure
pub fn walk_dir(p: &Path, f: fn((&Path)) -> bool) {
pub fn walk_dir(p: &Path, f: fn(&Path) -> bool) {
walk_dir_(p, f);
fn walk_dir_(p: &Path, f: fn((&Path)) -> bool) -> bool {
fn walk_dir_(p: &Path, f: fn(&Path) -> bool) -> bool {
let mut keepgoing = true;
do list_dir(p).each |q| {
let path = &p.push(*q);

View File

@ -140,7 +140,7 @@ impl ReprVisitor {
// Various helpers for the TyVisitor impl
#[inline(always)]
fn get<T>(f: fn((&T))) -> bool {
fn get<T>(f: fn(&T)) -> bool {
unsafe {
f(transmute::<*c_void,&T>(copy self.ptr));
}

View File

@ -143,7 +143,7 @@ pub fn chain_err<T, U, V>(
* print_buf(buf)
* }
*/
pub fn iter<T, E>(res: &Result<T, E>, f: fn((&T))) {
pub fn iter<T, E>(res: &Result<T, E>, f: fn(&T)) {
match *res {
Ok(ref t) => f(t),
Err(_) => ()
@ -158,7 +158,7 @@ pub fn iter<T, E>(res: &Result<T, E>, f: fn((&T))) {
* This function can be used to pass through a successful result while
* handling an error.
*/
pub fn iter_err<T, E>(res: &Result<T, E>, f: fn((&E))) {
pub fn iter_err<T, E>(res: &Result<T, E>, f: fn(&E)) {
match *res {
Ok(_) => (),
Err(ref e) => f(e)
@ -179,7 +179,7 @@ pub fn iter_err<T, E>(res: &Result<T, E>, f: fn((&E))) {
* parse_bytes(buf)
* }
*/
pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn((&T)) -> U)
pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn(&T) -> U)
-> Result<U, E> {
match *res {
Ok(ref t) => Ok(op(t)),
@ -195,7 +195,7 @@ pub fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn((&T)) -> U)
* is immediately returned. This function can be used to pass through a
* successful result while handling an error.
*/
pub fn map_err<T: Copy, E, F: Copy>(res: &Result<T, E>, op: fn((&E)) -> F)
pub fn map_err<T: Copy, E, F: Copy>(res: &Result<T, E>, op: fn(&E) -> F)
-> Result<T, F> {
match *res {
Ok(copy t) => Ok(t),
@ -210,14 +210,14 @@ impl<T, E> Result<T, E> {
pure fn is_err() -> bool { is_err(&self) }
pure fn iter(f: fn((&T))) {
pure fn iter(f: fn(&T)) {
match self {
Ok(ref t) => f(t),
Err(_) => ()
}
}
fn iter_err(f: fn((&E))) {
fn iter_err(f: fn(&E)) {
match self {
Ok(_) => (),
Err(ref e) => f(e)
@ -228,7 +228,7 @@ impl<T, E> Result<T, E> {
impl<T: Copy, E> Result<T, E> {
pure fn get() -> T { get(&self) }
fn map_err<F:Copy>(op: fn((&E)) -> F) -> Result<T,F> {
fn map_err<F:Copy>(op: fn(&E) -> F) -> Result<T,F> {
match self {
Ok(copy t) => Ok(t),
Err(ref e) => Err(op(e))
@ -239,7 +239,7 @@ impl<T: Copy, E> Result<T, E> {
impl<T, E: Copy> Result<T, E> {
pure fn get_err() -> E { get_err(&self) }
fn map<U:Copy>(op: fn((&T)) -> U) -> Result<U,E> {
fn map<U:Copy>(op: fn(&T) -> U) -> Result<U,E> {
match self {
Ok(ref t) => Ok(op(t)),
Err(copy e) => Err(e)
@ -277,7 +277,7 @@ impl<T: Copy, E: Copy> Result<T, E> {
* }
*/
pub fn map_vec<T,U:Copy,V:Copy>(
ts: &[T], op: fn((&T)) -> Result<V,U>) -> Result<~[V],U> {
ts: &[T], op: fn(&T) -> Result<V,U>) -> Result<~[V],U> {
let mut vs: ~[V] = vec::with_capacity(vec::len(ts));
for vec::each(ts) |t| {
@ -290,7 +290,7 @@ pub fn map_vec<T,U:Copy,V:Copy>(
}
pub fn map_opt<T,U:Copy,V:Copy>(
o_t: &Option<T>, op: fn((&T)) -> Result<V,U>) -> Result<Option<V>,U> {
o_t: &Option<T>, op: fn(&T) -> Result<V,U>) -> Result<Option<V>,U> {
match *o_t {
None => Ok(None),
@ -311,7 +311,7 @@ pub fn map_opt<T,U:Copy,V:Copy>(
* to accommodate an error like the vectors being of different lengths.
*/
pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
op: fn((&S),(&T)) -> Result<V,U>) -> Result<~[V],U> {
op: fn(&S,&T) -> Result<V,U>) -> Result<~[V],U> {
assert vec::same_length(ss, ts);
let n = vec::len(ts);
@ -333,7 +333,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T],
* on its own as no result vector is built.
*/
pub fn iter_vec2<S,T,U:Copy>(ss: &[S], ts: &[T],
op: fn((&S),(&T)) -> Result<(),U>) -> Result<(),U> {
op: fn(&S,&T) -> Result<(),U>) -> Result<(),U> {
assert vec::same_length(ss, ts);
let n = vec::len(ts);

View File

@ -1845,7 +1845,7 @@ const tag_six_b: uint = 252u;
* let i = str::as_bytes("Hello World") { |bytes| vec::len(bytes) };
* ~~~
*/
pub pure fn as_bytes<T>(s: &const ~str, f: fn((&~[u8])) -> T) -> T {
pub pure fn as_bytes<T>(s: &const ~str, f: fn(&~[u8]) -> T) -> T {
unsafe {
let v: *~[u8] = cast::transmute(copy s);
f(&*v)

View File

@ -1099,7 +1099,7 @@ pub pure fn reversed<T: Copy>(v: &[const T]) -> ~[T] {
* Return true to continue, false to break.
*/
#[inline(always)]
pub pure fn each<T>(v: &r/[T], f: fn((&r/T)) -> bool) {
pub pure fn each<T>(v: &r/[T], f: fn(&r/T) -> bool) {
// ^^^^
// NB---this CANNOT be &[const T]! The reason
// is that you are passing it to `f()` using

View File

@ -53,7 +53,7 @@ pub fn find<K: Eq Ord, V: Copy>(m: Treemap<K, V>, k: K) -> Option<V> {
}
/// Visit all pairs in the map in order.
pub fn traverse<K, V: Copy>(m: Treemap<K, V>, f: fn((&K), (&V))) {
pub fn traverse<K, V: Copy>(m: Treemap<K, V>, f: fn(&K, &V)) {
match *m {
Empty => (),
/*

View File

@ -51,7 +51,7 @@ impl<A> Future<A> {
get_ref(self)
}
fn with<B>(blk: fn((&A)) -> B) -> B {
fn with<B>(blk: fn(&A) -> B) -> B {
//! Work with the value without copying it
with(&self, blk)
@ -164,7 +164,7 @@ pub fn get<A:Copy>(future: &Future<A>) -> A {
*get_ref(future)
}
pub fn with<A,B>(future: &Future<A>, blk: fn((&A)) -> B) -> B {
pub fn with<A,B>(future: &Future<A>, blk: fn(&A) -> B) -> B {
//! Work with the value without copying it
blk(get_ref(future))

View File

@ -29,7 +29,7 @@ pub fn from_vec<T: Copy>(v: &[T]) -> @List<T> {
* * z - The initial value
* * f - The function to apply
*/
pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn(&T, &U) -> T) -> T {
let mut accum: T = z;
do iter(ls) |elt| { accum = f(&accum, elt);}
accum
@ -42,7 +42,7 @@ pub fn foldl<T: Copy, U>(z: T, ls: @List<U>, f: fn((&T), (&U)) -> T) -> T {
* When function `f` returns true then an option containing the element
* is returned. If `f` matches no elements then none is returned.
*/
pub fn find<T: Copy>(ls: @List<T>, f: fn((&T)) -> bool) -> Option<T> {
pub fn find<T: Copy>(ls: @List<T>, f: fn(&T) -> bool) -> Option<T> {
let mut ls = ls;
loop {
ls = match *ls {
@ -120,7 +120,7 @@ pure fn push<T: Copy>(ll: &mut @list<T>, vv: T) {
*/
/// Iterate over a list
pub fn iter<T>(l: @List<T>, f: fn((&T))) {
pub fn iter<T>(l: @List<T>, f: fn(&T)) {
let mut cur = l;
loop {
cur = match *cur {
@ -134,7 +134,7 @@ pub fn iter<T>(l: @List<T>, f: fn((&T))) {
}
/// Iterate over a list
pub fn each<T>(l: @List<T>, f: fn((&T)) -> bool) {
pub fn each<T>(l: @List<T>, f: fn(&T) -> bool) {
let mut cur = l;
loop {
cur = match *cur {