diff options
Diffstat (limited to 'src/libcore')
32 files changed, 335 insertions, 318 deletions
diff --git a/src/libcore/at_vec.rs b/src/libcore/at_vec.rs index 7a2a15a5421..fa19e24aa08 100644 --- a/src/libcore/at_vec.rs +++ b/src/libcore/at_vec.rs @@ -61,7 +61,7 @@ pub pure fn capacity<T>(v: @[const T]) -> uint { */ #[inline(always)] pub pure fn build_sized<A>(size: uint, - builder: &fn(push: pure fn(v: A))) -> @[A] { + builder: &fn(push: &pure fn(v: A))) -> @[A] { let mut vec: @[const A] = @[]; unsafe { raw::reserve(&mut vec, size); } builder(|+x| unsafe { raw::push(&mut vec, x) }); @@ -79,7 +79,7 @@ pub pure fn build_sized<A>(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] { +pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> @[A] { build_sized(4, builder) } @@ -97,7 +97,7 @@ pub pure fn build<A>(builder: &fn(push: pure fn(v: A))) -> @[A] { */ #[inline(always)] pub pure fn build_sized_opt<A>(size: Option<uint>, - builder: &fn(push: pure fn(v: A))) -> @[A] { + builder: &fn(push: &pure fn(v: A))) -> @[A] { build_sized(size.get_or_default(4), builder) } diff --git a/src/libcore/bool.rs b/src/libcore/bool.rs index 13b8d0fc907..512855d8f86 100644 --- a/src/libcore/bool.rs +++ b/src/libcore/bool.rs @@ -67,7 +67,7 @@ pub pure fn to_str(v: bool) -> ~str { if v { ~"true" } else { ~"false" } } * Iterates over all truth values by passing them to `blk` in an unspecified * order */ -pub fn all_values(blk: fn(v: bool)) { +pub fn all_values(blk: &fn(v: bool)) { blk(true); blk(false); } diff --git a/src/libcore/cell.rs b/src/libcore/cell.rs index 8df0037b2af..91a4ded60ef 100644 --- a/src/libcore/cell.rs +++ b/src/libcore/cell.rs @@ -54,7 +54,7 @@ pub impl<T> Cell<T> { } // Calls a closure with a reference to the value. - fn with_ref<R>(&self, op: fn(v: &T) -> R) -> R { + fn with_ref<R>(&self, op: &fn(v: &T) -> R) -> R { let v = self.take(); let r = op(&v); self.put_back(v); diff --git a/src/libcore/cleanup.rs b/src/libcore/cleanup.rs index bf1ea5f1150..faa6db45df2 100644 --- a/src/libcore/cleanup.rs +++ b/src/libcore/cleanup.rs @@ -124,7 +124,7 @@ struct AnnihilateStats { n_bytes_freed: uint } -unsafe fn each_live_alloc(f: fn(box: *mut BoxRepr, uniq: bool) -> bool) { +unsafe fn each_live_alloc(f: &fn(box: *mut BoxRepr, uniq: bool) -> bool) { use managed; let task: *Task = transmute(rustrt::rust_get_task()); diff --git a/src/libcore/container.rs b/src/libcore/container.rs index 36424d1bfaa..4f1f6004aad 100644 --- a/src/libcore/container.rs +++ b/src/libcore/container.rs @@ -30,10 +30,10 @@ pub trait Map<K, V>: Mutable { pure fn contains_key(&self, key: &K) -> bool; /// Visit all keys - pure fn each_key(&self, f: fn(&K) -> bool); + pure fn each_key(&self, f: &fn(&K) -> bool); /// Visit all values - pure fn each_value(&self, f: fn(&V) -> bool); + pure fn each_value(&self, f: &fn(&V) -> bool); /// Return the value corresponding to the key in the map pure fn find(&self, key: &K) -> Option<&self/V>; @@ -71,14 +71,14 @@ pub trait Set<T>: Mutable { pure fn is_superset(&self, other: &Self) -> bool; /// Visit the values representing the difference - pure fn difference(&self, other: &Self, f: fn(&T) -> bool); + pure fn difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the symmetric difference - pure fn symmetric_difference(&self, other: &Self, f: fn(&T) -> bool); + pure fn symmetric_difference(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the intersection - pure fn intersection(&self, other: &Self, f: fn(&T) -> bool); + pure fn intersection(&self, other: &Self, f: &fn(&T) -> bool); /// Visit the values representing the union - pure fn union(&self, other: &Self, f: fn(&T) -> bool); + pure fn union(&self, other: &Self, f: &fn(&T) -> bool); } diff --git a/src/libcore/core.rc b/src/libcore/core.rc index 4d686c8ab33..db1dc1e28aa 100644 --- a/src/libcore/core.rc +++ b/src/libcore/core.rc @@ -52,6 +52,7 @@ Implicitly, all crates behave as if they included the following prologue: #[deny(non_camel_case_types)]; #[allow(deprecated_mutable_fields)]; #[deny(deprecated_self)]; +#[allow(deprecated_drop)]; // On Linux, link to the runtime with -lrt. #[cfg(target_os = "linux")] diff --git a/src/libcore/dlist.rs b/src/libcore/dlist.rs index 9cb872a0542..1b5d03d9eb8 100644 --- a/src/libcore/dlist.rs +++ b/src/libcore/dlist.rs @@ -399,7 +399,7 @@ pub impl<T> DList<T> { } /// Iterate over nodes. - pure fn each_node(@mut self, f: fn(@mut DListNode<T>) -> bool) { + pure fn each_node(@mut self, f: &fn(@mut DListNode<T>) -> bool) { let mut link = self.peek_n(); while link.is_some() { let nobe = link.get(); @@ -507,7 +507,7 @@ impl<T> BaseIter<T> for @mut DList<T> { * allow for e.g. breadth-first search with in-place enqueues), but * removing the current node is forbidden. */ - pure fn each(&self, f: fn(v: &T) -> bool) { + pure fn each(&self, f: &fn(v: &T) -> bool) { let mut link = self.peek_n(); while option::is_some(&link) { let nobe = option::get(link); diff --git a/src/libcore/either.rs b/src/libcore/either.rs index e26f94261f9..e4b7bbbd99e 100644 --- a/src/libcore/either.rs +++ b/src/libcore/either.rs @@ -24,8 +24,8 @@ pub enum Either<T, U> { } #[inline(always)] -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 * @@ -148,7 +148,7 @@ pub pure fn unwrap_right<T,U>(eith: Either<T,U>) -> U { pub impl<T, U> Either<T, U> { #[inline(always)] - fn either<V>(&self, f_left: fn(&T) -> V, f_right: fn(&U) -> V) -> V { + fn either<V>(&self, f_left: &fn(&T) -> V, f_right: &fn(&U) -> V) -> V { either(f_left, f_right, self) } diff --git a/src/libcore/hashmap.rs b/src/libcore/hashmap.rs index 783f96d9b9e..2adcee495a7 100644 --- a/src/libcore/hashmap.rs +++ b/src/libcore/hashmap.rs @@ -86,7 +86,7 @@ pub mod linear { #[inline(always)] pure fn bucket_sequence(&self, hash: uint, - op: fn(uint) -> bool) -> uint { + op: &fn(uint) -> bool) -> uint { let start_idx = self.to_bucket(hash); let len_buckets = self.buckets.len(); let mut idx = start_idx; @@ -263,7 +263,7 @@ pub mod linear { } fn search(&self, hash: uint, - op: fn(x: &Option<Bucket<K, V>>) -> bool) { + op: &fn(x: &Option<Bucket<K, V>>) -> bool) { let _ = self.bucket_sequence(hash, |i| op(&self.buckets[i])); } } @@ -272,7 +272,7 @@ pub mod linear { BaseIter<(&self/K, &self/V)> for LinearMap<K, V> { /// Visit all key-value pairs - pure fn each(&self, blk: fn(&(&self/K, &self/V)) -> bool) { + pure fn each(&self, blk: &fn(&(&self/K, &self/V)) -> bool) { for uint::range(0, self.buckets.len()) |i| { let mut broke = false; do self.buckets[i].map |bucket| { @@ -315,12 +315,12 @@ pub mod linear { } /// Visit all keys - pure fn each_key(&self, blk: fn(k: &K) -> bool) { + pure fn each_key(&self, blk: &fn(k: &K) -> bool) { self.each(|&(k, _)| blk(k)) } /// Visit all values - pure fn each_value(&self, blk: fn(v: &V) -> bool) { + pure fn each_value(&self, blk: &fn(v: &V) -> bool) { self.each(|&(_, v)| blk(v)) } @@ -428,7 +428,7 @@ pub mod linear { /// Return the value corresponding to the key in the map, or create, /// insert, and return a new value if it doesn't exist. - fn find_or_insert_with(&mut self, k: K, f: fn(&K) -> V) -> &self/V { + fn find_or_insert_with(&mut self, k: K, f: &fn(&K) -> V) -> &self/V { if self.size >= self.resize_at { // n.b.: We could also do this after searching, so // that we do not resize if this call to insert is @@ -457,7 +457,7 @@ pub mod linear { } } - fn consume(&mut self, f: fn(K, V)) { + fn consume(&mut self, f: &fn(K, V)) { let mut buckets = ~[]; self.buckets <-> buckets; self.size = 0; @@ -526,7 +526,7 @@ pub mod linear { impl<T:Hash + IterBytes + Eq> BaseIter<T> for LinearSet<T> { /// Visit all values in order - pure fn each(&self, f: fn(&T) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&T) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } @@ -583,7 +583,7 @@ pub mod linear { } /// Visit the values representing the difference - pure fn difference(&self, other: &LinearSet<T>, f: fn(&T) -> bool) { + pure fn difference(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) { for self.each |v| { if !other.contains(v) { if !f(v) { return } @@ -593,13 +593,15 @@ pub mod linear { /// Visit the values representing the symmetric difference pure fn symmetric_difference(&self, other: &LinearSet<T>, - f: fn(&T) -> bool) { + f: &fn(&T) -> bool) { self.difference(other, f); other.difference(self, f); } /// Visit the values representing the intersection - pure fn intersection(&self, other: &LinearSet<T>, f: fn(&T) -> bool) { + pure fn intersection(&self, + other: &LinearSet<T>, + f: &fn(&T) -> bool) { for self.each |v| { if other.contains(v) { if !f(v) { return } @@ -608,7 +610,7 @@ pub mod linear { } /// Visit the values representing the union - pure fn union(&self, other: &LinearSet<T>, f: fn(&T) -> bool) { + pure fn union(&self, other: &LinearSet<T>, f: &fn(&T) -> bool) { for self.each |v| { if !f(v) { return } } diff --git a/src/libcore/io.rs b/src/libcore/io.rs index 4634eb8793d..b04bb15f5e3 100644 --- a/src/libcore/io.rs +++ b/src/libcore/io.rs @@ -118,13 +118,13 @@ pub trait ReaderUtil { fn read_whole_stream(&self) -> ~[u8]; /// Iterate over every byte until the iterator breaks or EOF. - fn each_byte(&self, it: fn(int) -> bool); + fn each_byte(&self, it: &fn(int) -> bool); /// Iterate over every char until the iterator breaks or EOF. - fn each_char(&self, it: fn(char) -> bool); + fn each_char(&self, it: &fn(char) -> bool); /// Iterate over every line until the iterator breaks or EOF. - fn each_line(&self, it: fn(&str) -> bool); + fn each_line(&self, it: &fn(&str) -> bool); /// Read n (between 1 and 8) little-endian unsigned integer bytes. fn read_le_uint_n(&self, nbytes: uint) -> u64; @@ -315,19 +315,19 @@ impl<T:Reader> ReaderUtil for T { bytes } - fn each_byte(&self, it: fn(int) -> bool) { + fn each_byte(&self, it: &fn(int) -> bool) { while !self.eof() { if !it(self.read_byte()) { break; } } } - fn each_char(&self, it: fn(char) -> bool) { + fn each_char(&self, it: &fn(char) -> bool) { while !self.eof() { if !it(self.read_char()) { break; } } } - fn each_line(&self, it: fn(s: &str) -> bool) { + fn each_line(&self, it: &fn(s: &str) -> bool) { while !self.eof() { if !it(self.read_line()) { break; } } @@ -618,11 +618,11 @@ impl Reader for BytesReader/&self { fn tell(&self) -> uint { self.pos } } -pub pure fn with_bytes_reader<t>(bytes: &[u8], f: fn(@Reader) -> t) -> t { +pub pure fn with_bytes_reader<t>(bytes: &[u8], f: &fn(@Reader) -> t) -> t { f(@BytesReader { bytes: bytes, pos: 0u } as @Reader) } -pub pure fn with_str_reader<T>(s: &str, f: fn(@Reader) -> T) -> T { +pub pure fn with_str_reader<T>(s: &str, f: &fn(@Reader) -> T) -> T { str::byte_slice(s, |bytes| with_bytes_reader(bytes, f)) } @@ -819,7 +819,7 @@ pub fn mk_file_writer(path: &Path, flags: &[FileFlag]) } pub fn u64_to_le_bytes<T>(n: u64, size: uint, - f: fn(v: &[u8]) -> T) -> T { + f: &fn(v: &[u8]) -> T) -> T { fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), @@ -851,7 +851,7 @@ pub fn u64_to_le_bytes<T>(n: u64, size: uint, } pub fn u64_to_be_bytes<T>(n: u64, size: uint, - f: fn(v: &[u8]) -> T) -> T { + f: &fn(v: &[u8]) -> T) -> T { fail_unless!(size <= 8u); match size { 1u => f(&[n as u8]), @@ -1142,14 +1142,14 @@ pub pure fn BytesWriter() -> BytesWriter { BytesWriter { bytes: ~[], mut pos: 0u } } -pub pure fn with_bytes_writer(f: fn(Writer)) -> ~[u8] { +pub pure fn with_bytes_writer(f: &fn(Writer)) -> ~[u8] { let wr = @BytesWriter(); f(wr as Writer); let @BytesWriter{bytes, _} = wr; return bytes; } -pub pure fn with_str_writer(f: fn(Writer)) -> ~str { +pub pure fn with_str_writer(f: &fn(Writer)) -> ~str { let mut v = with_bytes_writer(f); // FIXME (#3758): This should not be needed. @@ -1251,7 +1251,7 @@ pub mod fsync { // FIXME (#2004) find better way to create resources within lifetime of // outer res pub fn FILE_res_sync(file: &FILERes, opt_level: Option<Level>, - blk: fn(v: Res<*libc::FILE>)) { + blk: &fn(v: Res<*libc::FILE>)) { unsafe { blk(Res(Arg { val: file.f, opt_level: opt_level, @@ -1266,7 +1266,7 @@ pub mod fsync { // fsync fd after executing blk pub fn fd_res_sync(fd: &FdRes, opt_level: Option<Level>, - blk: fn(v: Res<fd_t>)) { + blk: &fn(v: Res<fd_t>)) { blk(Res(Arg { val: fd.fd, opt_level: opt_level, fsync_fn: |fd, l| os::fsync_fd(fd, l) as int @@ -1278,7 +1278,7 @@ pub mod fsync { // Call o.fsync after executing blk pub fn obj_sync(o: FSyncable, opt_level: Option<Level>, - blk: fn(v: Res<FSyncable>)) { + blk: &fn(v: Res<FSyncable>)) { blk(Res(Arg { val: o, opt_level: opt_level, fsync_fn: |o, l| o.fsync(l) diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index c92f747fc98..8931b408826 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -23,22 +23,22 @@ use vec; pub type InitOp<T> = &self/fn(uint) -> T; pub trait BaseIter<A> { - pure fn each(&self, blk: fn(v: &A) -> bool); + pure fn each(&self, blk: &fn(v: &A) -> bool); pure fn size_hint(&self) -> Option<uint>; } pub trait ReverseIter<A>: BaseIter<A> { - pure fn each_reverse(&self, blk: fn(&A) -> bool); + pure fn each_reverse(&self, blk: &fn(&A) -> bool); } pub trait ExtendedIter<A> { - pure fn eachi(&self, blk: fn(uint, v: &A) -> bool); - pure fn all(&self, blk: fn(&A) -> bool) -> bool; - pure fn any(&self, blk: fn(&A) -> bool) -> bool; - pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B; - pure fn position(&self, f: fn(&A) -> bool) -> Option<uint>; - pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B]; - pure fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: fn(&A) -> IB) + pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool); + pure fn all(&self, blk: &fn(&A) -> bool) -> bool; + pure fn any(&self, blk: &fn(&A) -> bool) -> bool; + pure fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B; + pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint>; + pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B]; + pure fn flat_map_to_vec<B,IB: BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B]; } @@ -48,13 +48,13 @@ pub trait EqIter<A:Eq> { } pub trait Times { - pure fn times(&self, it: fn() -> bool); + pure fn times(&self, it: &fn() -> bool); } pub trait CopyableIter<A:Copy> { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A]; + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A]; pure fn to_vec(&self) -> ~[A]; - pure fn find(&self, p: fn(&A) -> bool) -> Option<A>; + pure fn find(&self, p: &fn(&A) -> bool) -> Option<A>; } pub trait CopyableOrderedIter<A:Copy + Ord> { @@ -86,12 +86,12 @@ pub trait Buildable<A> { * onto the sequence being constructed. */ static pure fn build_sized(size: uint, - builder: fn(push: pure fn(A))) -> Self; + builder: &fn(push: &pure fn(A))) -> Self; } #[inline(always)] pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA, - blk: fn(uint, &A) -> bool) { + blk: &fn(uint, &A) -> bool) { let mut i = 0; for self.each |a| { if !blk(i, a) { break; } @@ -101,7 +101,7 @@ pub pure fn eachi<A,IA:BaseIter<A>>(self: &IA, #[inline(always)] pub pure fn all<A,IA:BaseIter<A>>(self: &IA, - blk: fn(&A) -> bool) -> bool { + blk: &fn(&A) -> bool) -> bool { for self.each |a| { if !blk(a) { return false; } } @@ -110,7 +110,7 @@ pub pure fn all<A,IA:BaseIter<A>>(self: &IA, #[inline(always)] pub pure fn any<A,IA:BaseIter<A>>(self: &IA, - blk: fn(&A) -> bool) -> bool { + blk: &fn(&A) -> bool) -> bool { for self.each |a| { if blk(a) { return true; } } @@ -119,7 +119,7 @@ pub pure fn any<A,IA:BaseIter<A>>(self: &IA, #[inline(always)] pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>( - self: &IA, prd: fn(&A) -> bool) -> ~[A] { + self: &IA, prd: &fn(&A) -> bool) -> ~[A] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { if prd(a) { push(*a); } @@ -129,7 +129,7 @@ pub pure fn filter_to_vec<A:Copy,IA:BaseIter<A>>( #[inline(always)] pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA, - op: fn(&A) -> B) + op: &fn(&A) -> B) -> ~[B] { do vec::build_sized_opt(self.size_hint()) |push| { for self.each |a| { @@ -140,7 +140,7 @@ pub pure fn map_to_vec<A,B,IA:BaseIter<A>>(self: &IA, #[inline(always)] pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>( - self: &IA, op: fn(&A) -> IB) -> ~[B] { + self: &IA, op: &fn(&A) -> IB) -> ~[B] { do vec::build |push| { for self.each |a| { for op(a).each |&b| { @@ -152,7 +152,7 @@ pub pure fn flat_map_to_vec<A,B,IA:BaseIter<A>,IB:BaseIter<B>>( #[inline(always)] pub pure fn foldl<A,B,IA:BaseIter<A>>(self: &IA, b0: B, - blk: fn(&B, &A) -> B) + blk: &fn(&B, &A) -> B) -> B { let mut b = b0; for self.each |a| { @@ -186,7 +186,7 @@ pub pure fn count<A:Eq,IA:BaseIter<A>>(self: &IA, x: &A) -> uint { } #[inline(always)] -pub pure fn position<A,IA:BaseIter<A>>(self: &IA, f: fn(&A) -> bool) +pub pure fn position<A,IA:BaseIter<A>>(self: &IA, f: &fn(&A) -> bool) -> Option<uint> { let mut i = 0; @@ -202,7 +202,7 @@ pub pure fn position<A,IA:BaseIter<A>>(self: &IA, f: fn(&A) -> bool) // it would have to be implemented with foldr, which is too inefficient. #[inline(always)] -pub pure fn repeat(times: uint, blk: fn() -> bool) { +pub pure fn repeat(times: uint, blk: &fn() -> bool) { let mut i = 0; while i < times { if !blk() { break } @@ -242,7 +242,7 @@ pub pure fn max<A:Copy + Ord,IA:BaseIter<A>>(self: &IA) -> A { #[inline(always)] pub pure fn find<A:Copy,IA:BaseIter<A>>(self: &IA, - f: fn(&A) -> bool) -> Option<A> { + f: &fn(&A) -> bool) -> Option<A> { for self.each |i| { if f(i) { return Some(*i) } } @@ -262,7 +262,7 @@ pub pure fn find<A:Copy,IA:BaseIter<A>>(self: &IA, * onto the sequence being constructed. */ #[inline(always)] -pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A))) +pub pure fn build<A,B: Buildable<A>>(builder: &fn(push: &pure fn(A))) -> B { Buildable::build_sized(4, builder) } @@ -283,7 +283,7 @@ pub pure fn build<A,B: Buildable<A>>(builder: fn(push: pure fn(A))) #[inline(always)] pub pure fn build_sized_opt<A,B: Buildable<A>>( size: Option<uint>, - builder: fn(push: pure fn(A))) -> B { + builder: &fn(push: &pure fn(A))) -> B { Buildable::build_sized(size.get_or_default(4), builder) } @@ -292,7 +292,7 @@ pub pure fn build_sized_opt<A,B: Buildable<A>>( /// Applies a function to each element of an iterable and returns the results. #[inline(always)] -pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: fn(&T) -> U) +pub fn map<T,IT: BaseIter<T>,U,BU: Buildable<U>>(v: &IT, f: &fn(&T) -> U) -> BU { do build_sized_opt(v.size_hint()) |push| { for v.each() |elem| { diff --git a/src/libcore/num/int-template.rs b/src/libcore/num/int-template.rs index 2f59b4c50de..cef8542823a 100644 --- a/src/libcore/num/int-template.rs +++ b/src/libcore/num/int-template.rs @@ -100,7 +100,7 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } */ #[inline(always)] /// Iterate over the range [`start`,`start`+`step`..`stop`) -pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { +pub pure fn range_step(start: T, stop: T, step: T, it: &fn(T) -> bool) { let mut i = start; if step == 0 { fail!(~"range_step called with step == 0"); @@ -119,13 +119,13 @@ pub pure fn range_step(start: T, stop: T, step: T, it: fn(T) -> bool) { #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: fn(T) -> bool) { +pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: fn(T) -> bool) { +pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T, it); } @@ -237,7 +237,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { +pub pure fn to_str_bytes<U>(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) diff --git a/src/libcore/num/uint-template.rs b/src/libcore/num/uint-template.rs index 11bd7dbfd3a..9abbfb03d7a 100644 --- a/src/libcore/num/uint-template.rs +++ b/src/libcore/num/uint-template.rs @@ -67,7 +67,10 @@ pub pure fn is_nonnegative(x: T) -> bool { x >= 0 as T } * Iterate over the range [`start`,`start`+`step`..`stop`) * */ -pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { +pub pure fn range_step(start: T, + stop: T, + step: T_SIGNED, + it: &fn(T) -> bool) { let mut i = start; if step == 0 { fail!(~"range_step called with step == 0"); @@ -88,13 +91,13 @@ pub pure fn range_step(start: T, stop: T, step: T_SIGNED, it: fn(T) -> bool) { #[inline(always)] /// Iterate over the range [`lo`..`hi`) -pub pure fn range(lo: T, hi: T, it: fn(T) -> bool) { +pub pure fn range(lo: T, hi: T, it: &fn(T) -> bool) { range_step(lo, hi, 1 as T_SIGNED, it); } #[inline(always)] /// Iterate over the range [`hi`..`lo`) -pub pure fn range_rev(hi: T, lo: T, it: fn(T) -> bool) { +pub pure fn range_rev(hi: T, lo: T, it: &fn(T) -> bool) { range_step(hi, lo, -1 as T_SIGNED, it); } @@ -200,7 +203,7 @@ impl FromStrRadix for T { /// Convert to a string as a byte slice in a given base. #[inline(always)] -pub pure fn to_str_bytes<U>(n: T, radix: uint, f: fn(v: &[u8]) -> U) -> U { +pub pure fn to_str_bytes<U>(n: T, radix: uint, f: &fn(v: &[u8]) -> U) -> U { let (buf, _) = strconv::to_str_bytes_common(&n, radix, false, strconv::SignNeg, strconv::DigAll); f(buf) diff --git a/src/libcore/num/uint-template/uint.rs b/src/libcore/num/uint-template/uint.rs index 6814b0e7541..f73ff4442ce 100644 --- a/src/libcore/num/uint-template/uint.rs +++ b/src/libcore/num/uint-template/uint.rs @@ -101,7 +101,7 @@ pub mod inst { * `true` If execution proceeded correctly, `false` if it was interrupted, * that is if `it` returned `false` at any point. */ - pub pure fn iterate(lo: uint, hi: uint, it: fn(uint) -> bool) -> bool { + pub pure fn iterate(lo: uint, hi: uint, it: &fn(uint) -> bool) -> bool { let mut i = lo; while i < hi { if (!it(i)) { return false; } @@ -122,7 +122,7 @@ pub mod inst { * use with integer literals of inferred integer-type as * the self-value (eg. `for 100.times { ... }`). */ - pure fn times(&self, it: fn() -> bool) { + pure fn times(&self, it: &fn() -> bool) { let mut i = *self; while i > 0 { if !it() { break } diff --git a/src/libcore/option.rs b/src/libcore/option.rs index 7b0e4d07b53..e0393fdf5e3 100644 --- a/src/libcore/option.rs +++ b/src/libcore/option.rs @@ -131,7 +131,7 @@ pub pure fn get_ref<T>(opt: &r/Option<T>) -> &r/T { } #[inline(always)] -pub pure fn map<T, U>(opt: &r/Option<T>, f: fn(x: &r/T) -> U) -> Option<U> { +pub pure fn map<T, U>(opt: &r/Option<T>, f: &fn(x: &r/T) -> U) -> Option<U> { //! Maps a `some` value by reference from one type to another match *opt { Some(ref x) => Some(f(x)), None => None } @@ -139,7 +139,7 @@ pub pure fn map<T, U>(opt: &r/Option<T>, f: fn(x: &r/T) -> U) -> Option<U> { #[inline(always)] pub pure fn map_consume<T, U>(opt: Option<T>, - f: fn(v: T) -> U) -> Option<U> { + f: &fn(v: T) -> U) -> Option<U> { /*! * As `map`, but consumes the option and gives `f` ownership to avoid * copying. @@ -149,7 +149,7 @@ pub pure fn map_consume<T, U>(opt: Option<T>, #[inline(always)] pub pure fn chain<T, U>(opt: Option<T>, - f: fn(t: T) -> Option<U>) -> Option<U> { + f: &fn(t: T) -> Option<U>) -> Option<U> { /*! * Update an optional value by optionally running its content through a * function that returns an option. @@ -163,7 +163,7 @@ pub pure fn chain<T, U>(opt: Option<T>, #[inline(always)] pub pure fn chain_ref<T, U>(opt: &Option<T>, - f: fn(x: &T) -> Option<U>) -> Option<U> { + f: &fn(x: &T) -> Option<U>) -> Option<U> { /*! * Update an optional value by optionally running its content by reference * through a function that returns an option. @@ -184,7 +184,7 @@ pub pure fn or<T>(opta: Option<T>, optb: Option<T>) -> Option<T> { } #[inline(always)] -pub pure fn while_some<T>(x: Option<T>, blk: fn(v: T) -> Option<T>) { +pub pure fn while_some<T>(x: Option<T>, blk: &fn(v: T) -> Option<T>) { //! Applies a function zero or more times until the result is none. let mut opt = x; @@ -223,7 +223,7 @@ pub pure fn get_or_default<T:Copy>(opt: Option<T>, def: T) -> T { #[inline(always)] pub pure fn map_default<T, U>(opt: &r/Option<T>, def: U, - f: fn(&r/T) -> U) -> U { + f: &fn(&r/T) -> U) -> U { //! Applies a function to the contained value or returns a default match *opt { None => def, Some(ref t) => f(t) } @@ -279,7 +279,7 @@ pub pure fn expect<T>(opt: Option<T>, reason: &str) -> T { impl<T> BaseIter<T> for Option<T> { /// Performs an operation on the contained value by reference #[inline(always)] - pure fn each(&self, f: fn(x: &self/T) -> bool) { + pure fn each(&self, f: &fn(x: &self/T) -> bool) { match *self { None => (), Some(ref t) => { f(t); } } } @@ -303,43 +303,43 @@ pub impl<T> Option<T> { * through a function that returns an option. */ #[inline(always)] - pure fn chain_ref<U>(&self, f: fn(x: &T) -> Option<U>) -> Option<U> { + pure fn chain_ref<U>(&self, f: &fn(x: &T) -> Option<U>) -> Option<U> { chain_ref(self, f) } /// Maps a `some` value from one type to another by reference #[inline(always)] - pure fn map<U>(&self, f: fn(&self/T) -> U) -> Option<U> { map(self, f) } + pure fn map<U>(&self, f: &fn(&self/T) -> U) -> Option<U> { map(self, f) } /// As `map`, but consumes the option and gives `f` ownership to avoid /// copying. #[inline(always)] - pure fn map_consume<U>(self, f: fn(v: T) -> U) -> Option<U> { + pure fn map_consume<U>(self, f: &fn(v: T) -> U) -> Option<U> { map_consume(self, f) } /// Applies a function to the contained value or returns a default #[inline(always)] - pure fn map_default<U>(&self, def: U, f: fn(&self/T) -> U) -> U { + pure fn map_default<U>(&self, def: U, f: &fn(&self/T) -> U) -> U { map_default(self, def, f) } /// As `map_default`, but consumes the option and gives `f` /// ownership to avoid copying. #[inline(always)] - pure fn map_consume_default<U>(self, def: U, f: fn(v: T) -> U) -> U { + pure fn map_consume_default<U>(self, def: U, f: &fn(v: T) -> U) -> U { match self { None => def, Some(v) => f(v) } } /// Apply a function to the contained value or do nothing - fn mutate(&mut self, f: fn(T) -> T) { + fn mutate(&mut self, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } } /// Apply a function to the contained value or set it to a default - fn mutate_default(&mut self, def: T, f: fn(T) -> T) { + fn mutate_default(&mut self, def: T, f: &fn(T) -> T) { if self.is_some() { *self = Some(f(self.swap_unwrap())); } else { @@ -420,7 +420,7 @@ pub impl<T:Copy> Option<T> { /// Applies a function zero or more times until the result is none. #[inline(always)] - pure fn while_some(self, blk: fn(v: T) -> Option<T>) { + pure fn while_some(self, blk: &fn(v: T) -> Option<T>) { while_some(self, blk) } } diff --git a/src/libcore/os.rs b/src/libcore/os.rs index 5c73e45364b..ba16c14a85a 100644 --- a/src/libcore/os.rs +++ b/src/libcore/os.rs @@ -75,11 +75,11 @@ pub fn getcwd() -> Path { } } -pub fn as_c_charp<T>(s: &str, f: fn(*c_char) -> T) -> T { +pub fn as_c_charp<T>(s: &str, f: &fn(*c_char) -> T) -> T { str::as_c_str(s, |b| f(b as *c_char)) } -pub fn fill_charp_buf(f: fn(*mut c_char, size_t) -> bool) +pub fn fill_charp_buf(f: &fn(*mut c_char, size_t) -> bool) -> Option<~str> { let mut buf = vec::from_elem(TMPBUF_SZ, 0u8 as c_char); do vec::as_mut_buf(buf) |b, sz| { @@ -103,7 +103,7 @@ pub mod win32 { use os::TMPBUF_SZ; use libc::types::os::arch::extra::DWORD; - pub fn fill_utf16_buf_and_decode(f: fn(*mut u16, DWORD) -> DWORD) + pub fn fill_utf16_buf_and_decode(f: &fn(*mut u16, DWORD) -> DWORD) -> Option<~str> { unsafe { let mut n = TMPBUF_SZ as DWORD; @@ -133,7 +133,7 @@ pub mod win32 { } } - pub fn as_utf16_p<T>(s: &str, f: fn(*u16) -> T) -> T { + pub fn as_utf16_p<T>(s: &str, f: &fn(*u16) -> T) -> T { let mut t = str::to_utf16(s); // Null terminate before passing on. t += ~[0u16]; @@ -518,11 +518,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); diff --git a/src/libcore/pipes.rs b/src/libcore/pipes.rs index afb7aef25a3..fd823e9dda0 100644 --- a/src/libcore/pipes.rs +++ b/src/libcore/pipes.rs @@ -246,7 +246,7 @@ pub fn packet<T>() -> *Packet<T> { #[doc(hidden)] pub fn entangle_buffer<T:Owned,Tstart:Owned>( buffer: ~Buffer<T>, - init: fn(*libc::c_void, x: &T) -> *Packet<Tstart>) + init: &fn(*libc::c_void, x: &T) -> *Packet<Tstart>) -> (SendPacketBuffered<Tstart, T>, RecvPacketBuffered<Tstart, T>) { let p = init(unsafe { reinterpret_cast(&buffer) }, &buffer.data); diff --git a/src/libcore/ptr.rs b/src/libcore/ptr.rs index ebf41dc48f4..b66c1c4696f 100644 --- a/src/libcore/ptr.rs +++ b/src/libcore/ptr.rs @@ -82,7 +82,7 @@ pub unsafe fn buf_len<T>(buf: **T) -> uint { /// Return the first offset `i` such that `f(buf[i]) == true`. #[inline(always)] -pub unsafe fn position<T>(buf: *T, f: fn(&T) -> bool) -> uint { +pub unsafe fn position<T>(buf: *T, f: &fn(&T) -> bool) -> uint { let mut i = 0; loop { if f(&(*offset(buf, i))) { return i; } diff --git a/src/libcore/reflect.rs b/src/libcore/reflect.rs index f29447ef53e..30c46cd3e35 100644 --- a/src/libcore/reflect.rs +++ b/src/libcore/reflect.rs @@ -26,7 +26,7 @@ use vec; * then build a MovePtrAdaptor wrapped around your struct. */ pub trait MovePtr { - fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void); + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void); fn push_ptr(&self); fn pop_ptr(&self); } diff --git a/src/libcore/repr.rs b/src/libcore/repr.rs index e9122754eb4..ad85c5e5cef 100644 --- a/src/libcore/repr.rs +++ b/src/libcore/repr.rs @@ -159,7 +159,7 @@ pub fn ReprVisitor(ptr: *c_void, writer: @Writer) -> ReprVisitor { impl MovePtr for ReprVisitor { #[inline(always)] - fn move_ptr(&self, adjustment: fn(*c_void) -> *c_void) { + fn move_ptr(&self, adjustment: &fn(*c_void) -> *c_void) { self.ptr = adjustment(self.ptr); } fn push_ptr(&self) { @@ -175,7 +175,7 @@ pub impl ReprVisitor { // Various helpers for the TyVisitor impl #[inline(always)] - fn get<T>(&self, f: fn(&T)) -> bool { + fn get<T>(&self, f: &fn(&T)) -> bool { unsafe { f(transmute::<*c_void,&T>(copy self.ptr)); } diff --git a/src/libcore/result.rs b/src/libcore/result.rs index dd9b55e6725..e3fd279a996 100644 --- a/src/libcore/result.rs +++ b/src/libcore/result.rs @@ -122,7 +122,7 @@ pub pure fn to_either<T:Copy,U:Copy>(res: &Result<U, T>) * } */ #[inline(always)] -pub pure fn chain<T, U, V>(res: Result<T, V>, op: fn(T) +pub pure fn chain<T, U, V>(res: Result<T, V>, op: &fn(T) -> Result<U, V>) -> Result<U, V> { match res { Ok(t) => op(t), @@ -141,7 +141,7 @@ pub pure fn chain<T, U, V>(res: Result<T, V>, op: fn(T) #[inline(always)] pub pure fn chain_err<T, U, V>( res: Result<T, V>, - op: fn(t: V) -> Result<T, U>) + op: &fn(t: V) -> Result<T, U>) -> Result<T, U> { match res { Ok(t) => Ok(t), @@ -164,7 +164,7 @@ pub pure fn chain_err<T, U, V>( * } */ #[inline(always)] -pub pure fn iter<T, E>(res: &Result<T, E>, f: fn(&T)) { +pub pure fn iter<T, E>(res: &Result<T, E>, f: &fn(&T)) { match *res { Ok(ref t) => f(t), Err(_) => () @@ -180,7 +180,7 @@ pub pure fn iter<T, E>(res: &Result<T, E>, f: fn(&T)) { * handling an error. */ #[inline(always)] -pub pure fn iter_err<T, E>(res: &Result<T, E>, f: fn(&E)) { +pub pure fn iter_err<T, E>(res: &Result<T, E>, f: &fn(&E)) { match *res { Ok(_) => (), Err(ref e) => f(e) @@ -202,7 +202,7 @@ pub pure fn iter_err<T, E>(res: &Result<T, E>, f: fn(&E)) { * } */ #[inline(always)] -pub pure fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn(&T) -> U) +pub pure 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)), @@ -219,7 +219,7 @@ pub pure fn map<T, E: Copy, U: Copy>(res: &Result<T, E>, op: fn(&T) -> U) * successful result while handling an error. */ #[inline(always)] -pub pure fn map_err<T:Copy,E,F:Copy>(res: &Result<T, E>, op: fn(&E) -> F) +pub pure 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), @@ -238,10 +238,10 @@ pub impl<T, E> Result<T, E> { pure fn is_err(&self) -> bool { is_err(self) } #[inline(always)] - pure fn iter(&self, f: fn(&T)) { iter(self, f) } + pure fn iter(&self, f: &fn(&T)) { iter(self, f) } #[inline(always)] - pure fn iter_err(&self, f: fn(&E)) { iter_err(self, f) } + pure fn iter_err(&self, f: &fn(&E)) { iter_err(self, f) } #[inline(always)] pure fn unwrap(self) -> T { unwrap(self) } @@ -250,12 +250,12 @@ pub impl<T, E> Result<T, E> { pure fn unwrap_err(self) -> E { unwrap_err(self) } #[inline(always)] - pure fn chain<U>(self, op: fn(T) -> Result<U,E>) -> Result<U,E> { + pure fn chain<U>(self, op: &fn(T) -> Result<U,E>) -> Result<U,E> { chain(self, op) } #[inline(always)] - pure fn chain_err<F>(self, op: fn(E) -> Result<T,F>) -> Result<T,F> { + pure fn chain_err<F>(self, op: &fn(E) -> Result<T,F>) -> Result<T,F> { chain_err(self, op) } } @@ -265,7 +265,7 @@ pub impl<T:Copy,E> Result<T, E> { pure fn get(&self) -> T { get(self) } #[inline(always)] - pure fn map_err<F:Copy>(&self, op: fn(&E) -> F) -> Result<T,F> { + pure fn map_err<F:Copy>(&self, op: &fn(&E) -> F) -> Result<T,F> { map_err(self, op) } } @@ -275,7 +275,7 @@ pub impl<T, E: Copy> Result<T, E> { pure fn get_err(&self) -> E { get_err(self) } #[inline(always)] - pure fn map<U:Copy>(&self, op: fn(&T) -> U) -> Result<U,E> { + pure fn map<U:Copy>(&self, op: &fn(&T) -> U) -> Result<U,E> { map(self, op) } } @@ -299,7 +299,7 @@ pub impl<T, E: Copy> Result<T, E> { */ #[inline(always)] 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| { @@ -313,7 +313,7 @@ pub fn map_vec<T,U:Copy,V:Copy>( #[inline(always)] 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), @@ -335,7 +335,7 @@ pub fn map_opt<T,U:Copy,V:Copy>( */ #[inline(always)] 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> { fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); @@ -358,7 +358,7 @@ pub fn map_vec2<S,T,U:Copy,V:Copy>(ss: &[S], ts: &[T], */ #[inline(always)] 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> { fail_unless!(vec::same_length(ss, ts)); let n = vec::len(ts); diff --git a/src/libcore/run.rs b/src/libcore/run.rs index bebcc909dc6..a9d96d891c9 100644 --- a/src/libcore/run.rs +++ b/src/libcore/run.rs @@ -102,7 +102,7 @@ pub fn spawn_process(prog: &str, args: &[~str], } fn with_argv<T>(prog: &str, args: &[~str], - cb: fn(**libc::c_char) -> T) -> T { + cb: &fn(**libc::c_char) -> T) -> T { let mut argptrs = str::as_c_str(prog, |b| ~[b]); let mut tmps = ~[]; for vec::each(args) |arg| { @@ -116,7 +116,7 @@ fn with_argv<T>(prog: &str, args: &[~str], #[cfg(unix)] fn with_envp<T>(env: &Option<~[(~str,~str)]>, - cb: fn(*c_void) -> T) -> T { + cb: &fn(*c_void) -> T) -> T { // On posixy systems we can pass a char** for envp, which is // a null-terminated array of "k=v\n" strings. match *env { @@ -141,7 +141,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>, #[cfg(windows)] fn with_envp<T>(env: &Option<~[(~str,~str)]>, - cb: fn(*c_void) -> T) -> T { + cb: &fn(*c_void) -> T) -> T { // On win32 we pass an "environment block" which is not a char**, but // rather a concatenation of null-terminated k=v\0 sequences, with a final // \0 to terminate. @@ -165,7 +165,7 @@ fn with_envp<T>(env: &Option<~[(~str,~str)]>, } fn with_dirp<T>(d: &Option<~str>, - cb: fn(*libc::c_char) -> T) -> T { + cb: &fn(*libc::c_char) -> T) -> T { match *d { Some(ref dir) => str::as_c_str(*dir, cb), None => cb(ptr::null()) diff --git a/src/libcore/stackwalk.rs b/src/libcore/stackwalk.rs index 107e52b245e..955e486649b 100644 --- a/src/libcore/stackwalk.rs +++ b/src/libcore/stackwalk.rs @@ -24,7 +24,7 @@ pub fn Frame(fp: *Word) -> Frame { } } -pub fn walk_stack(visit: fn(Frame) -> bool) { +pub fn walk_stack(visit: &fn(Frame) -> bool) { debug!("beginning stack walk"); @@ -80,7 +80,7 @@ fn breakpoint() { } } -fn frame_address(f: fn(++x: *u8)) { +fn frame_address(f: &fn(++x: *u8)) { unsafe { rusti::frame_address(f) } diff --git a/src/libcore/str.rs b/src/libcore/str.rs index 6a0673878e0..ae778cb7649 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -382,7 +382,7 @@ pub pure fn to_bytes(s: &str) -> ~[u8] { /// Work with the string as a byte slice, not including trailing null. #[inline(always)] -pub pure fn byte_slice<T>(s: &str, f: fn(v: &[u8]) -> T) -> T { +pub pure fn byte_slice<T>(s: &str, f: &fn(v: &[u8]) -> T) -> T { do as_buf(s) |p,n| { unsafe { vec::raw::buf_as_slice(p, n-1u, f) } } @@ -483,7 +483,7 @@ pure fn split_char_inner(s: &str, sep: char, count: uint, allow_empty: bool) /// Splits a string into substrings using a character function -pub pure fn split(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { +pub pure fn split(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), true) } @@ -491,16 +491,19 @@ pub pure fn split(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { * Splits a string into substrings using a character function, cutting at * most `count` times. */ -pub pure fn splitn(s: &str, sepfn: fn(char) -> bool, count: uint) -> ~[~str] { +pub pure fn splitn(s: &str, + sepfn: &fn(char) -> bool, + count: uint) + -> ~[~str] { split_inner(s, sepfn, count, true) } /// Like `split`, but omits empty strings from the returned vector -pub pure fn split_nonempty(s: &str, sepfn: fn(char) -> bool) -> ~[~str] { +pub pure fn split_nonempty(s: &str, sepfn: &fn(char) -> bool) -> ~[~str] { split_inner(s, sepfn, len(s), false) } -pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, +pure fn split_inner(s: &str, sepfn: &fn(cc: char) -> bool, count: uint, allow_empty: bool) -> ~[~str] { let l = len(s); let mut result = ~[], i = 0u, start = 0u, done = 0u; @@ -526,7 +529,7 @@ pure fn split_inner(s: &str, sepfn: fn(cc: char) -> bool, count: uint, } // See Issue #1932 for why this is a naive search -pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { +pure fn iter_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { let sep_len = len(sep), l = len(s); fail_unless!(sep_len > 0u); let mut i = 0u, match_start = 0u, match_i = 0u; @@ -553,7 +556,7 @@ pure fn iter_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { } } -pure fn iter_between_matches(s: &a/str, sep: &b/str, f: fn(uint, uint)) { +pure fn iter_between_matches(s: &a/str, sep: &b/str, f: &fn(uint, uint)) { let mut last_end = 0u; do iter_matches(s, sep) |from, to| { f(last_end, from); @@ -912,7 +915,7 @@ Section: Iterating through strings * Return true if a predicate matches all characters or if the string * contains no characters */ -pub pure fn all(s: &str, it: fn(char) -> bool) -> bool { +pub pure fn all(s: &str, it: &fn(char) -> bool) -> bool { all_between(s, 0u, len(s), it) } @@ -920,12 +923,12 @@ pub pure fn all(s: &str, it: fn(char) -> bool) -> bool { * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ -pub pure fn any(ss: &str, pred: fn(char) -> bool) -> bool { +pub pure fn any(ss: &str, pred: &fn(char) -> bool) -> bool { !all(ss, |cc| !pred(cc)) } /// Apply a function to each character -pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str { +pub pure fn map(ss: &str, ff: &fn(char) -> char) -> ~str { let mut result = ~""; unsafe { reserve(&mut result, len(ss)); @@ -937,7 +940,7 @@ pub pure fn map(ss: &str, ff: fn(char) -> char) -> ~str { } /// Iterate over the bytes in a string -pub pure fn bytes_each(ss: &str, it: fn(u8) -> bool) { +pub pure fn bytes_each(ss: &str, it: &fn(u8) -> bool) { let mut pos = 0u; let len = len(ss); @@ -949,13 +952,13 @@ pub pure fn bytes_each(ss: &str, it: fn(u8) -> bool) { /// Iterate over the bytes in a string #[inline(always)] -pub pure fn each(s: &str, it: fn(u8) -> bool) { +pub pure fn each(s: &str, it: &fn(u8) -> bool) { eachi(s, |_i, b| it(b) ) } /// Iterate over the bytes in a string, with indices #[inline(always)] -pub pure fn eachi(s: &str, it: fn(uint, u8) -> bool) { +pub pure fn eachi(s: &str, it: &fn(uint, u8) -> bool) { let mut i = 0u, l = len(s); while (i < l) { if !it(i, s[i]) { break; } @@ -965,13 +968,13 @@ pub pure fn eachi(s: &str, it: fn(uint, u8) -> bool) { /// Iterates over the chars in a string #[inline(always)] -pub pure fn each_char(s: &str, it: fn(char) -> bool) { +pub pure fn each_char(s: &str, it: &fn(char) -> bool) { each_chari(s, |_i, c| it(c)) } /// Iterates over the chars in a string, with indices #[inline(always)] -pub pure fn each_chari(s: &str, it: fn(uint, char) -> bool) { +pub pure fn each_chari(s: &str, it: &fn(uint, char) -> bool) { let mut pos = 0u, ch_pos = 0u; let len = len(s); while pos < len { @@ -983,7 +986,7 @@ pub pure fn each_chari(s: &str, it: fn(uint, char) -> bool) { } /// Iterate over the characters in a string -pub pure fn chars_each(s: &str, it: fn(char) -> bool) { +pub pure fn chars_each(s: &str, it: &fn(char) -> bool) { let mut pos = 0u; let len = len(s); while (pos < len) { @@ -994,7 +997,7 @@ pub pure fn chars_each(s: &str, it: fn(char) -> bool) { } /// Apply a function to each substring after splitting by character -pub pure fn split_char_each(ss: &str, cc: char, ff: fn(v: &str) -> bool) { +pub pure fn split_char_each(ss: &str, cc: char, ff: &fn(v: &str) -> bool) { vec::each(split_char(ss, cc), |s| ff(*s)) } @@ -1003,19 +1006,19 @@ pub pure fn split_char_each(ss: &str, cc: char, ff: fn(v: &str) -> bool) { * `count` times */ pub pure fn splitn_char_each(ss: &str, sep: char, count: uint, - ff: fn(v: &str) -> bool) { + ff: &fn(v: &str) -> bool) { vec::each(splitn_char(ss, sep, count), |s| ff(*s)) } /// Apply a function to each word -pub pure fn words_each(ss: &str, ff: fn(v: &str) -> bool) { +pub pure fn words_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(words(ss), |s| ff(*s)) } /** * Apply a function to each line (by '\n') */ -pub pure fn lines_each(ss: &str, ff: fn(v: &str) -> bool) { +pub pure fn lines_each(ss: &str, ff: &fn(v: &str) -> bool) { vec::each(lines(ss), |s| ff(*s)) } @@ -1195,7 +1198,7 @@ pub pure fn rfind_char_between(s: &str, c: char, start: uint, end: uint) * An `option` containing the byte index of the first matching character * or `none` if there is no match */ -pub pure fn find(s: &str, f: fn(char) -> bool) -> Option<uint> { +pub pure fn find(s: &str, f: &fn(char) -> bool) -> Option<uint> { find_between(s, 0u, len(s), f) } @@ -1219,7 +1222,7 @@ pub pure fn find(s: &str, f: fn(char) -> bool) -> Option<uint> { * `start` must be less than or equal to `len(s)`. `start` must be the * index of a character boundary, as defined by `is_char_boundary`. */ -pub pure fn find_from(s: &str, start: uint, f: fn(char) +pub pure fn find_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option<uint> { find_between(s, start, len(s), f) } @@ -1246,8 +1249,11 @@ pub pure fn find_from(s: &str, start: uint, f: fn(char) * or equal to `len(s)`. `start` must be the index of a character * boundary, as defined by `is_char_boundary`. */ -pub pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) - -> Option<uint> { +pub pure fn find_between(s: &str, + start: uint, + end: uint, + f: &fn(char) -> bool) + -> Option<uint> { fail_unless!(start <= end); fail_unless!(end <= len(s)); fail_unless!(is_char_boundary(s, start)); @@ -1274,7 +1280,7 @@ pub pure fn find_between(s: &str, start: uint, end: uint, f: fn(char) -> bool) * An option containing the byte index of the last matching character * or `none` if there is no match */ -pub pure fn rfind(s: &str, f: fn(char) -> bool) -> Option<uint> { +pub pure fn rfind(s: &str, f: &fn(char) -> bool) -> Option<uint> { rfind_between(s, len(s), 0u, f) } @@ -1298,7 +1304,7 @@ pub pure fn rfind(s: &str, f: fn(char) -> bool) -> Option<uint> { * `start` must be less than or equal to `len(s)', `start` must be the * index of a character boundary, as defined by `is_char_boundary` */ -pub pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) +pub pure fn rfind_from(s: &str, start: uint, f: &fn(char) -> bool) -> Option<uint> { rfind_between(s, start, 0u, f) } @@ -1326,7 +1332,7 @@ pub pure fn rfind_from(s: &str, start: uint, f: fn(char) -> bool) * boundary, as defined by `is_char_boundary` */ pub pure fn rfind_between(s: &str, start: uint, end: uint, - f: fn(char) -> bool) + f: &fn(char) -> bool) -> Option<uint> { fail_unless!(start >= end); fail_unless!(start <= len(s)); @@ -1589,7 +1595,7 @@ pub pure fn to_utf16(s: &str) -> ~[u16] { u } -pub pure fn utf16_chars(v: &[u16], f: fn(char)) { +pub pure fn utf16_chars(v: &[u16], f: &fn(char)) { let len = vec::len(v); let mut i = 0u; while (i < len && v[i] != 0u16) { @@ -1815,7 +1821,7 @@ pure fn char_range_at_reverse(ss: &str, start: uint) -> CharRange { * that is if `it` returned `false` at any point. */ pub pure fn all_between(s: &str, start: uint, end: uint, - it: fn(char) -> bool) -> bool { + it: &fn(char) -> bool) -> bool { fail_unless!(is_char_boundary(s, start)); let mut i = start; while i < end { @@ -1848,7 +1854,7 @@ pub pure fn all_between(s: &str, start: uint, end: uint, * `true` if `it` returns `true` for any character */ pub pure fn any_between(s: &str, start: uint, end: uint, - it: fn(char) -> bool) -> bool { + it: &fn(char) -> bool) -> bool { !all_between(s, start, end, |c| !it(c)) } @@ -1886,7 +1892,7 @@ pub const nan_buf: [u8*3] = ['N' as u8, 'a' as u8, 'N' as u8]; * 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) @@ -1921,7 +1927,7 @@ pub pure fn as_bytes_slice(s: &a/str) -> &a/[u8] { * let s = str::as_c_str("PATH", { |path| libc::getenv(path) }); * ~~~ */ -pub pure fn as_c_str<T>(s: &str, f: fn(*libc::c_char) -> T) -> T { +pub pure fn as_c_str<T>(s: &str, f: &fn(*libc::c_char) -> T) -> T { do as_buf(s) |buf, len| { // NB: len includes the trailing null. fail_unless!(len > 0); @@ -1943,7 +1949,7 @@ pub pure fn as_c_str<T>(s: &str, f: fn(*libc::c_char) -> T) -> T { * to full strings, or suffixes of them. */ #[inline(always)] -pub pure fn as_buf<T>(s: &str, f: fn(*u8, uint) -> T) -> T { +pub pure fn as_buf<T>(s: &str, f: &fn(*u8, uint) -> T) -> T { unsafe { let v : *(*u8,uint) = ::cast::reinterpret_cast(&ptr::addr_of(&s)); let (buf,len) = *v; @@ -2088,7 +2094,7 @@ pub mod raw { /// Form a slice from a *u8 buffer of the given length without copying. pub unsafe fn buf_as_slice<T>(buf: *u8, len: uint, - f: fn(v: &str) -> T) -> T { + f: &fn(v: &str) -> T) -> T { let v = (buf, len + 1); fail_unless!(is_utf8(::cast::reinterpret_cast(&v))); f(::cast::transmute(v)) @@ -2238,21 +2244,21 @@ pub mod traits { pub mod traits {} pub trait StrSlice { - pure fn all(&self, it: fn(char) -> bool) -> bool; - pure fn any(&self, it: fn(char) -> bool) -> bool; + pure fn all(&self, it: &fn(char) -> bool) -> bool; + pure fn any(&self, it: &fn(char) -> bool) -> bool; pure fn contains(&self, needle: &a/str) -> bool; pure fn contains_char(&self, needle: char) -> bool; - pure fn each(&self, it: fn(u8) -> bool); - pure fn eachi(&self, it: fn(uint, u8) -> bool); - pure fn each_char(&self, it: fn(char) -> bool); - pure fn each_chari(&self, it: fn(uint, char) -> bool); + pure fn each(&self, it: &fn(u8) -> bool); + pure fn eachi(&self, it: &fn(uint, u8) -> bool); + pure fn each_char(&self, it: &fn(char) -> bool); + pure fn each_chari(&self, it: &fn(uint, char) -> bool); pure fn ends_with(&self, needle: &str) -> bool; pure fn is_empty(&self) -> bool; pure fn is_whitespace(&self) -> bool; pure fn is_alphanumeric(&self) -> bool; pure fn len(&self) -> uint; pure fn slice(&self, begin: uint, end: uint) -> ~str; - pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str]; + pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str]; pure fn split_char(&self, sep: char) -> ~[~str]; pure fn split_str(&self, sep: &a/str) -> ~[~str]; pure fn starts_with(&self, needle: &a/str) -> bool; @@ -2276,13 +2282,13 @@ impl StrSlice for &self/str { * contains no characters */ #[inline] - pure fn all(&self, it: fn(char) -> bool) -> bool { all(*self, it) } + pure fn all(&self, it: &fn(char) -> bool) -> bool { all(*self, it) } /** * Return true if a predicate matches any character (and false if it * matches none or there are no characters) */ #[inline] - pure fn any(&self, it: fn(char) -> bool) -> bool { any(*self, it) } + pure fn any(&self, it: &fn(char) -> bool) -> bool { any(*self, it) } /// Returns true if one string contains another #[inline] pure fn contains(&self, needle: &a/str) -> bool { @@ -2295,16 +2301,16 @@ impl StrSlice for &self/str { } /// Iterate over the bytes in a string #[inline] - pure fn each(&self, it: fn(u8) -> bool) { each(*self, it) } + pure fn each(&self, it: &fn(u8) -> bool) { each(*self, it) } /// Iterate over the bytes in a string, with indices #[inline] - pure fn eachi(&self, it: fn(uint, u8) -> bool) { eachi(*self, it) } + pure fn eachi(&self, it: &fn(uint, u8) -> bool) { eachi(*self, it) } /// Iterate over the chars in a string #[inline] - pure fn each_char(&self, it: fn(char) -> bool) { each_char(*self, it) } + pure fn each_char(&self, it: &fn(char) -> bool) { each_char(*self, it) } /// Iterate over the chars in a string, with indices #[inline] - pure fn each_chari(&self, it: fn(uint, char) -> bool) { + pure fn each_chari(&self, it: &fn(uint, char) -> bool) { each_chari(*self, it) } /// Returns true if one string ends with another @@ -2345,7 +2351,7 @@ impl StrSlice for &self/str { } /// Splits a string into substrings using a character function #[inline] - pure fn split(&self, sepfn: fn(char) -> bool) -> ~[~str] { + pure fn split(&self, sepfn: &fn(char) -> bool) -> ~[~str] { split(*self, sepfn) } /** diff --git a/src/libcore/sys.rs b/src/libcore/sys.rs index d4db61f4519..179a33ae43e 100644 --- a/src/libcore/sys.rs +++ b/src/libcore/sys.rs @@ -227,7 +227,7 @@ pub mod tests { pub fn synthesize_closure() { unsafe { let x = 10; - let f: fn(int) -> int = |y| x + y; + let f: &fn(int) -> int = |y| x + y; fail_unless!(f(20) == 30); @@ -241,7 +241,7 @@ pub mod tests { env: environment }; - let new_f: fn(int) -> int = cast::transmute(new_closure); + let new_f: &fn(int) -> int = cast::transmute(new_closure); fail_unless!(new_f(20) == 30); } } diff --git a/src/libcore/task/local_data.rs b/src/libcore/task/local_data.rs index 72c328d4613..690b3aedc5a 100644 --- a/src/libcore/task/local_data.rs +++ b/src/libcore/task/local_data.rs @@ -79,7 +79,7 @@ pub unsafe fn local_data_set<T:Durable>( */ pub unsafe fn local_data_modify<T:Durable>( key: LocalDataKey<T>, - modify_fn: fn(Option<@T>) -> Option<@T>) { + modify_fn: &fn(Option<@T>) -> Option<@T>) { local_modify(rt::rust_get_task(), key, modify_fn) } diff --git a/src/libcore/task/local_data_priv.rs b/src/libcore/task/local_data_priv.rs index f035916f594..bb05520e1a3 100644 --- a/src/libcore/task/local_data_priv.rs +++ b/src/libcore/task/local_data_priv.rs @@ -176,7 +176,7 @@ pub unsafe fn local_set<T:Durable>( pub unsafe fn local_modify<T:Durable>( task: *rust_task, key: LocalDataKey<T>, - modify_fn: fn(Option<@T>) -> Option<@T>) { + modify_fn: &fn(Option<@T>) -> Option<@T>) { // Could be more efficient by doing the lookup work, but this is easy. let newdata = modify_fn(local_pop(task, key)); diff --git a/src/libcore/task/mod.rs b/src/libcore/task/mod.rs index 065feaebb51..31c44531efe 100644 --- a/src/libcore/task/mod.rs +++ b/src/libcore/task/mod.rs @@ -295,7 +295,7 @@ pub impl TaskBuilder { * # Failure * Fails if a future_result was already set for this task. */ - fn future_result(&self, blk: fn(v: Port<TaskResult>)) -> TaskBuilder { + fn future_result(&self, blk: &fn(v: Port<TaskResult>)) -> TaskBuilder { // FIXME (#3725): Once linked failure and notification are // handled in the library, I can imagine implementing this by just // registering an arbitrary number of task::on_exit handlers and @@ -572,7 +572,7 @@ pub fn get_scheduler() -> Scheduler { * } * ~~~ */ -pub unsafe fn unkillable<U>(f: fn() -> U) -> U { +pub unsafe fn unkillable<U>(f: &fn() -> U) -> U { struct AllowFailure { t: *rust_task, drop { @@ -597,7 +597,7 @@ pub unsafe fn unkillable<U>(f: fn() -> U) -> U { } /// The inverse of unkillable. Only ever to be used nested in unkillable(). -pub unsafe fn rekillable<U>(f: fn() -> U) -> U { +pub unsafe fn rekillable<U>(f: &fn() -> U) -> U { struct DisallowFailure { t: *rust_task, drop { @@ -625,7 +625,7 @@ pub unsafe fn rekillable<U>(f: fn() -> U) -> U { * A stronger version of unkillable that also inhibits scheduling operations. * For use with exclusive ARCs, which use pthread mutexes directly. */ -pub unsafe fn atomically<U>(f: fn() -> U) -> U { +pub unsafe fn atomically<U>(f: &fn() -> U) -> U { struct DeferInterrupts { t: *rust_task, drop { diff --git a/src/libcore/task/spawn.rs b/src/libcore/task/spawn.rs index 7b7ec769fa9..a0db2525441 100644 --- a/src/libcore/task/spawn.rs +++ b/src/libcore/task/spawn.rs @@ -108,7 +108,7 @@ fn taskset_remove(tasks: &mut TaskSet, task: *rust_task) { let was_present = tasks.remove(&task); fail_unless!(was_present); } -pub fn taskset_each(tasks: &TaskSet, blk: fn(v: *rust_task) -> bool) { +pub fn taskset_each(tasks: &TaskSet, blk: &fn(v: *rust_task) -> bool) { tasks.each(|k| blk(*k)) } @@ -151,17 +151,17 @@ struct AncestorNode { mut ancestors: AncestorList, } -enum AncestorList = Option<unstable::Exclusive<AncestorNode>>; +struct AncestorList(Option<unstable::Exclusive<AncestorNode>>); // Accessors for taskgroup arcs and ancestor arcs that wrap the unsafety. #[inline(always)] -fn access_group<U>(x: &TaskGroupArc, blk: fn(TaskGroupInner) -> U) -> U { +fn access_group<U>(x: &TaskGroupArc, blk: &fn(TaskGroupInner) -> U) -> U { unsafe { x.with(blk) } } #[inline(always)] fn access_ancestors<U>(x: &unstable::Exclusive<AncestorNode>, - blk: fn(x: &mut AncestorNode) -> U) -> U { + blk: &fn(x: &mut AncestorNode) -> U) -> U { unsafe { x.with(blk) } } @@ -175,7 +175,7 @@ fn access_ancestors<U>(x: &unstable::Exclusive<AncestorNode>, // allocations. Once that bug is fixed, changing the sigil should suffice. fn each_ancestor(list: &mut AncestorList, bail_opt: Option<@fn(TaskGroupInner)>, - forward_blk: fn(TaskGroupInner) -> bool) + forward_blk: &fn(TaskGroupInner) -> bool) -> bool { // "Kickoff" call - there was no last generation. return !coalesce(list, bail_opt, forward_blk, uint::max_value); @@ -184,7 +184,7 @@ fn each_ancestor(list: &mut AncestorList, // whether or not unwinding is needed (i.e., !successful iteration). fn coalesce(list: &mut AncestorList, bail_opt: Option<@fn(TaskGroupInner)>, - forward_blk: fn(TaskGroupInner) -> bool, + forward_blk: &fn(TaskGroupInner) -> bool, last_generation: uint) -> bool { // Need to swap the list out to use it, to appease borrowck. let tmp_list = util::replace(&mut *list, AncestorList(None)); @@ -288,7 +288,7 @@ fn each_ancestor(list: &mut AncestorList, // Wrapper around exclusive::with that appeases borrowck. fn with_parent_tg<U>(parent_group: &mut Option<TaskGroupArc>, - blk: fn(TaskGroupInner) -> U) -> U { + blk: &fn(TaskGroupInner) -> U) -> U { // If this trips, more likely the problem is 'blk' failed inside. let tmp_arc = option::swap_unwrap(&mut *parent_group); let result = do access_group(&tmp_arc) |tg_opt| { blk(tg_opt) }; diff --git a/src/libcore/trie.rs b/src/libcore/trie.rs index 395772df571..7dc85cba297 100644 --- a/src/libcore/trie.rs +++ b/src/libcore/trie.rs @@ -32,7 +32,7 @@ pub struct TrieMap<T> { impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> { /// Visit all key-value pairs in order #[inline(always)] - pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) { + pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) { self.root.each(f); } #[inline(always)] @@ -42,7 +42,7 @@ impl<T> BaseIter<(uint, &'self T)> for TrieMap<T> { impl<T> ReverseIter<(uint, &'self T)> for TrieMap<T> { /// Visit all key-value pairs in reverse order #[inline(always)] - pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) { + pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) { self.root.each_reverse(f); } } @@ -75,13 +75,16 @@ impl<T> Map<uint, T> for TrieMap<T> { /// Visit all keys in order #[inline(always)] - pure fn each_key(&self, f: fn(&uint) -> bool) { + pure fn each_key(&self, f: &fn(&uint) -> bool) { self.each(|&(k, _)| f(&k)) } /// Visit all values in order #[inline(always)] - pure fn each_value(&self, f: fn(&T) -> bool) { self.each(|&(_, v)| f(v)) } + pure fn each_value(&self, + f: &fn(&T) -> bool) { + self.each(|&(_, v)| f(v)) + } /// Return the value corresponding to the key in the map #[inline(hint)] @@ -138,18 +141,18 @@ impl<T> TrieMap<T> { impl<T> TrieMap<T> { /// Visit all keys in reverse order #[inline(always)] - pure fn each_key_reverse(&self, f: fn(&uint) -> bool) { + pure fn each_key_reverse(&self, f: &fn(&uint) -> bool) { self.each_reverse(|&(k, _)| f(&k)) } /// Visit all values in reverse order #[inline(always)] - pure fn each_value_reverse(&self, f: fn(&T) -> bool) { + pure fn each_value_reverse(&self, f: &fn(&T) -> bool) { self.each_reverse(|&(_, v)| f(v)) } /// Iterate over the map and mutate the contained values - fn mutate_values(&mut self, f: fn(uint, &mut T) -> bool) { + fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) { self.root.mutate_values(f); } } @@ -160,13 +163,13 @@ pub struct TrieSet { impl BaseIter<uint> for TrieSet { /// Visit all values in order - pure fn each(&self, f: fn(&uint) -> bool) { self.map.each_key(f) } + pure fn each(&self, f: &fn(&uint) -> bool) { self.map.each_key(f) } pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } impl ReverseIter<uint> for TrieSet { /// Visit all values in reverse order - pure fn each_reverse(&self, f: fn(&uint) -> bool) { + pure fn each_reverse(&self, f: &fn(&uint) -> bool) { self.map.each_key_reverse(f) } } @@ -223,7 +226,7 @@ impl<T> TrieNode<T> { } impl<T> TrieNode<T> { - pure fn each(&self, f: fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { for uint::range(0, self.children.len()) |idx| { match self.children[idx] { Internal(ref x) => if !x.each(f) { return false }, @@ -234,7 +237,7 @@ impl<T> TrieNode<T> { true } - pure fn each_reverse(&self, f: fn(&(uint, &self/T)) -> bool) -> bool { + pure fn each_reverse(&self, f: &fn(&(uint, &self/T)) -> bool) -> bool { for uint::range_rev(self.children.len(), 0) |idx| { match self.children[idx - 1] { Internal(ref x) => if !x.each_reverse(f) { return false }, @@ -245,7 +248,7 @@ impl<T> TrieNode<T> { true } - fn mutate_values(&mut self, f: fn(uint, &mut T) -> bool) -> bool { + fn mutate_values(&mut self, f: &fn(uint, &mut T) -> bool) -> bool { for vec::each_mut(self.children) |child| { match *child { Internal(ref mut x) => if !x.mutate_values(f) { diff --git a/src/libcore/unstable.rs b/src/libcore/unstable.rs index 96cd732d815..4f45535d0f8 100644 --- a/src/libcore/unstable.rs +++ b/src/libcore/unstable.rs @@ -232,7 +232,7 @@ fn LittleLock() -> LittleLock { pub impl LittleLock { #[inline(always)] - unsafe fn lock<T>(&self, f: fn() -> T) -> T { + unsafe fn lock<T>(&self, f: &fn() -> T) -> T { struct Unlock { l: rust_little_lock, drop { @@ -284,7 +284,7 @@ pub impl<T:Owned> Exclusive<T> { // accessing the provided condition variable) are prohibited while inside // the exclusive. Supporting that is a work in progress. #[inline(always)] - unsafe fn with<U>(&self, f: fn(x: &mut T) -> U) -> U { + unsafe fn with<U>(&self, f: &fn(x: &mut T) -> U) -> U { unsafe { let rec = get_shared_mutable_state(&self.x); do (*rec).lock.lock { @@ -301,7 +301,7 @@ pub impl<T:Owned> Exclusive<T> { } #[inline(always)] - unsafe fn with_imm<U>(&self, f: fn(x: &T) -> U) -> U { + unsafe fn with_imm<U>(&self, f: &fn(x: &T) -> U) -> U { do self.with |x| { f(cast::transmute_immut(x)) } diff --git a/src/libcore/vec.rs b/src/libcore/vec.rs index 655db1c83d0..aed98f3573e 100644 --- a/src/libcore/vec.rs +++ b/src/libcore/vec.rs @@ -175,7 +175,7 @@ pub pure fn with_capacity<T>(capacity: uint) -> ~[T] { */ #[inline(always)] pub pure fn build_sized<A>(size: uint, - builder: fn(push: pure fn(v: A))) -> ~[A] { + builder: &fn(push: &pure fn(v: A))) -> ~[A] { let mut vec = with_capacity(size); builder(|x| unsafe { vec.push(x) }); vec @@ -192,7 +192,7 @@ pub pure fn build_sized<A>(size: uint, * onto the vector being constructed. */ #[inline(always)] -pub pure fn build<A>(builder: fn(push: pure fn(v: A))) -> ~[A] { +pub pure fn build<A>(builder: &fn(push: &pure fn(v: A))) -> ~[A] { build_sized(4, builder) } @@ -210,7 +210,7 @@ pub pure fn build<A>(builder: fn(push: pure fn(v: A))) -> ~[A] { */ #[inline(always)] pub pure fn build_sized_opt<A>(size: Option<uint>, - builder: fn(push: pure fn(v: A))) -> ~[A] { + builder: &fn(push: &pure fn(v: A))) -> ~[A] { build_sized(size.get_or_default(4), builder) } @@ -305,7 +305,7 @@ pub pure fn const_slice<T>(v: &r/[const T], /// Copies /// Split the vector `v` by applying each element against the predicate `f`. -pub fn split<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn split<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -328,7 +328,7 @@ pub fn split<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Split the vector `v` by applying each element against the predicate `f` up * to `n` times. */ -pub fn splitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn splitn<T:Copy>(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -354,7 +354,7 @@ pub fn splitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f`. */ -pub fn rsplit<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplit<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0) { return ~[] } @@ -378,7 +378,7 @@ pub fn rsplit<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[~[T]] { * Reverse split the vector `v` by applying each element against the predicate * `f` up to `n times. */ -pub fn rsplitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { +pub fn rsplitn<T:Copy>(v: &[T], n: uint, f: &fn(t: &T) -> bool) -> ~[~[T]] { let ln = len(v); if (ln == 0u) { return ~[] } @@ -405,7 +405,7 @@ pub fn rsplitn<T:Copy>(v: &[T], n: uint, f: fn(t: &T) -> bool) -> ~[~[T]] { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub fn partition<T>(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { +pub fn partition<T>(v: ~[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -426,7 +426,7 @@ pub fn partition<T>(v: ~[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { * Partitions a vector into two new vectors: those that satisfies the * predicate, and those that do not. */ -pub pure fn partitioned<T:Copy>(v: &[T], f: fn(&T) -> bool) -> (~[T], ~[T]) { +pub pure fn partitioned<T:Copy>(v: &[T], f: &fn(&T) -> bool) -> (~[T], ~[T]) { let mut lefts = ~[]; let mut rights = ~[]; @@ -535,7 +535,7 @@ pub fn remove<T>(v: &mut ~[T], i: uint) -> T { v.pop() } -pub fn consume<T>(mut v: ~[T], f: fn(uint, v: T)) { +pub fn consume<T>(mut v: ~[T], f: &fn(uint, v: T)) { unsafe { do as_mut_buf(v) |p, ln| { for uint::range(0, ln) |i| { @@ -780,7 +780,7 @@ pub fn grow_set<T:Copy>(v: &mut ~[T], index: uint, initval: &T, val: T) { // Functional utilities /// Apply a function to each element of a vector and return the results -pub pure fn map<T, U>(v: &[T], f: fn(t: &T) -> U) -> ~[U] { +pub pure fn map<T, U>(v: &[T], f: &fn(t: &T) -> U) -> ~[U] { let mut result = with_capacity(len(v)); for each(v) |elem| { unsafe { @@ -790,7 +790,7 @@ pub pure fn map<T, U>(v: &[T], f: fn(t: &T) -> U) -> ~[U] { result } -pub fn map_consume<T, U>(v: ~[T], f: fn(v: T) -> U) -> ~[U] { +pub fn map_consume<T, U>(v: ~[T], f: &fn(v: T) -> U) -> ~[U] { let mut result = ~[]; do consume(v) |_i, x| { result.push(f(x)); @@ -799,7 +799,7 @@ pub fn map_consume<T, U>(v: ~[T], f: fn(v: T) -> U) -> ~[U] { } /// Apply a function to each element of a vector and return the results -pub pure fn mapi<T, U>(v: &[T], f: fn(uint, t: &T) -> U) -> ~[U] { +pub pure fn mapi<T, U>(v: &[T], f: &fn(uint, t: &T) -> U) -> ~[U] { let mut i = 0; do map(v) |e| { i += 1; @@ -811,7 +811,7 @@ pub pure fn mapi<T, U>(v: &[T], f: fn(uint, t: &T) -> U) -> ~[U] { * Apply a function to each element of a vector and return a concatenation * of each result vector */ -pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { +pub pure fn flat_map<T, U>(v: &[T], f: &fn(t: &T) -> ~[U]) -> ~[U] { let mut result = ~[]; for each(v) |elem| { unsafe{ result.push_all_move(f(elem)); } } result @@ -819,7 +819,7 @@ pub pure fn flat_map<T, U>(v: &[T], f: fn(t: &T) -> ~[U]) -> ~[U] { /// Apply a function to each pair of elements and return the results pub pure fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U], - f: fn(t: &T, v: &U) -> V) -> ~[V] { + f: &fn(t: &T, v: &U) -> V) -> ~[V] { let v0_len = len(v0); if v0_len != len(v1) { fail!(); } let mut u: ~[V] = ~[]; @@ -833,7 +833,7 @@ pub pure fn map2<T:Copy,U:Copy,V>(v0: &[T], v1: &[U], pub fn filter_map<T, U>( v: ~[T], - f: fn(t: T) -> Option<U>) -> ~[U] + f: &fn(t: T) -> Option<U>) -> ~[U] { /*! * @@ -854,7 +854,7 @@ pub fn filter_map<T, U>( pub pure fn filter_mapped<T, U: Copy>( v: &[T], - f: fn(t: &T) -> Option<U>) -> ~[U] + f: &fn(t: &T) -> Option<U>) -> ~[U] { /*! * @@ -879,7 +879,7 @@ pub pure fn filter_mapped<T, U: Copy>( * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub fn filter<T>(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { +pub fn filter<T>(v: ~[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; // FIXME (#4355 maybe): using v.consume here crashes // do v.consume |_, elem| { @@ -896,7 +896,7 @@ pub fn filter<T>(v: ~[T], f: fn(t: &T) -> bool) -> ~[T] { * Apply function `f` to each element of `v` and return a vector containing * only those elements for which `f` returned true. */ -pub pure fn filtered<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { +pub pure fn filtered<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> ~[T] { let mut result = ~[]; for each(v) |elem| { if f(elem) { unsafe { result.push(*elem); } } @@ -907,7 +907,7 @@ pub pure fn filtered<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> ~[T] { /** * Like `filter()`, but in place. Preserves order of `v`. Linear time. */ -pub fn retain<T>(v: &mut ~[T], f: pure fn(t: &T) -> bool) { +pub fn retain<T>(v: &mut ~[T], f: &pure fn(t: &T) -> bool) { let len = v.len(); let mut deleted: uint = 0; @@ -963,7 +963,7 @@ pub pure fn connect<T:Copy>(v: &[~[T]], sep: &T) -> ~[T] { * ~~~ * */ -pub pure fn foldl<T, U>(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { +pub pure fn foldl<T, U>(z: T, v: &[U], p: &fn(t: T, u: &U) -> T) -> T { let mut accum = z; let mut i = 0; let l = v.len(); @@ -995,7 +995,7 @@ pub pure fn foldl<T, U>(z: T, v: &[U], p: fn(t: T, u: &U) -> T) -> T { * ~~~ * */ -pub pure fn foldr<T, U: Copy>(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { +pub pure fn foldr<T, U: Copy>(v: &[T], z: U, p: &fn(t: &T, u: U) -> U) -> U { let mut accum = z; for rev_each(v) |elt| { accum = p(elt, accum); @@ -1008,7 +1008,7 @@ pub pure fn foldr<T, U: Copy>(v: &[T], z: U, p: fn(t: &T, u: U) -> U) -> U { * * If the vector contains no elements then false is returned. */ -pub pure fn any<T>(v: &[T], f: fn(t: &T) -> bool) -> bool { +pub pure fn any<T>(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if f(elem) { return true; } } false } @@ -1019,7 +1019,7 @@ pub pure fn any<T>(v: &[T], f: fn(t: &T) -> bool) -> bool { * If the vectors contains no elements then false is returned. */ pub pure fn any2<T, U>(v0: &[T], v1: &[U], - f: fn(a: &T, b: &U) -> bool) -> bool { + f: &fn(a: &T, b: &U) -> bool) -> bool { let v0_len = len(v0); let v1_len = len(v1); let mut i = 0u; @@ -1035,7 +1035,7 @@ pub pure fn any2<T, U>(v0: &[T], v1: &[U], * * If the vector contains no elements then true is returned. */ -pub pure fn all<T>(v: &[T], f: fn(t: &T) -> bool) -> bool { +pub pure fn all<T>(v: &[T], f: &fn(t: &T) -> bool) -> bool { for each(v) |elem| { if !f(elem) { return false; } } true } @@ -1045,7 +1045,7 @@ pub pure fn all<T>(v: &[T], f: fn(t: &T) -> bool) -> bool { * * If the vector contains no elements then true is returned. */ -pub pure fn alli<T>(v: &[T], f: fn(uint, t: &T) -> bool) -> bool { +pub pure fn alli<T>(v: &[T], f: &fn(uint, t: &T) -> bool) -> bool { for eachi(v) |i, elem| { if !f(i, elem) { return false; } } true } @@ -1056,7 +1056,7 @@ pub pure fn alli<T>(v: &[T], f: fn(uint, t: &T) -> bool) -> bool { * If the vectors are not the same size then false is returned. */ pub pure fn all2<T, U>(v0: &[T], v1: &[U], - f: fn(t: &T, u: &U) -> bool) -> bool { + f: &fn(t: &T, u: &U) -> bool) -> bool { let v0_len = len(v0); if v0_len != len(v1) { return false; } let mut i = 0u; @@ -1084,7 +1084,7 @@ pub pure fn count<T:Eq>(v: &[T], x: &T) -> uint { * When function `f` returns true then an option containing the element * is returned. If `f` matches no elements then none is returned. */ -pub pure fn find<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { +pub pure fn find<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T> { find_between(v, 0u, len(v), f) } @@ -1096,7 +1096,7 @@ pub pure fn find<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { * the element is returned. If `f` matches no elements then none is returned. */ pub pure fn find_between<T:Copy>(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option<T> { + f: &fn(t: &T) -> bool) -> Option<T> { position_between(v, start, end, f).map(|i| v[*i]) } @@ -1107,7 +1107,7 @@ pub pure fn find_between<T:Copy>(v: &[T], start: uint, end: uint, * `f` returns true then an option containing the element is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rfind<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { +pub pure fn rfind<T:Copy>(v: &[T], f: &fn(t: &T) -> bool) -> Option<T> { rfind_between(v, 0u, len(v), f) } @@ -1119,7 +1119,7 @@ pub pure fn rfind<T:Copy>(v: &[T], f: fn(t: &T) -> bool) -> Option<T> { * the element is returned. If `f` matches no elements then none is return. */ pub pure fn rfind_between<T:Copy>(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option<T> { + f: &fn(t: &T) -> bool) -> Option<T> { rposition_between(v, start, end, f).map(|i| v[*i]) } @@ -1135,7 +1135,7 @@ pub pure fn position_elem<T:Eq>(v: &[T], x: &T) -> Option<uint> { * then an option containing the index is returned. If `f` matches no elements * then none is returned. */ -pub pure fn position<T>(v: &[T], f: fn(t: &T) -> bool) -> Option<uint> { +pub pure fn position<T>(v: &[T], f: &fn(t: &T) -> bool) -> Option<uint> { position_between(v, 0u, len(v), f) } @@ -1147,7 +1147,7 @@ pub pure fn position<T>(v: &[T], f: fn(t: &T) -> bool) -> Option<uint> { * the index is returned. If `f` matches no elements then none is returned. */ pub pure fn position_between<T>(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option<uint> { + f: &fn(t: &T) -> bool) -> Option<uint> { fail_unless!(start <= end); fail_unless!(end <= len(v)); let mut i = start; @@ -1167,7 +1167,7 @@ pure fn rposition_elem<T:Eq>(v: &[T], x: &T) -> Option<uint> { * `f` returns true then an option containing the index is returned. If `f` * matches no elements then none is returned. */ -pub pure fn rposition<T>(v: &[T], f: fn(t: &T) -> bool) -> Option<uint> { +pub pure fn rposition<T>(v: &[T], f: &fn(t: &T) -> bool) -> Option<uint> { rposition_between(v, 0u, len(v), f) } @@ -1180,7 +1180,7 @@ pub pure fn rposition<T>(v: &[T], f: fn(t: &T) -> bool) -> Option<uint> { * returned. */ pub pure fn rposition_between<T>(v: &[T], start: uint, end: uint, - f: fn(t: &T) -> bool) -> Option<uint> { + f: &fn(t: &T) -> bool) -> Option<uint> { fail_unless!(start <= end); fail_unless!(end <= len(v)); let mut i = end; @@ -1334,7 +1334,7 @@ pub pure fn reversed<T:Copy>(v: &[const T]) -> ~[T] { * ~~~ */ #[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 @@ -1358,7 +1358,7 @@ pub pure fn each<T>(v: &r/[T], f: fn(&r/T) -> bool) { /// a vector with mutable contents and you would like /// to mutate the contents as you iterate. #[inline(always)] -pub fn each_mut<T>(v: &mut [T], f: fn(elem: &mut T) -> bool) { +pub fn each_mut<T>(v: &mut [T], f: &fn(elem: &mut T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1372,7 +1372,7 @@ pub fn each_mut<T>(v: &mut [T], f: fn(elem: &mut T) -> bool) { /// Like `each()`, but for the case where you have a vector that *may or may /// not* have mutable contents. #[inline(always)] -pub pure fn each_const<T>(v: &[const T], f: fn(elem: &const T) -> bool) { +pub pure fn each_const<T>(v: &[const T], f: &fn(elem: &const T) -> bool) { let mut i = 0; let n = v.len(); while i < n { @@ -1389,7 +1389,7 @@ pub pure fn each_const<T>(v: &[const T], f: fn(elem: &const T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn eachi<T>(v: &r/[T], f: fn(uint, v: &r/T) -> bool) { +pub pure fn eachi<T>(v: &r/[T], f: &fn(uint, v: &r/T) -> bool) { let mut i = 0; for each(v) |p| { if !f(i, p) { return; } @@ -1403,7 +1403,7 @@ pub pure fn eachi<T>(v: &r/[T], f: fn(uint, v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_each<T>(v: &r/[T], blk: fn(v: &r/T) -> bool) { +pub pure fn rev_each<T>(v: &r/[T], blk: &fn(v: &r/T) -> bool) { rev_eachi(v, |_i, v| blk(v)) } @@ -1413,7 +1413,7 @@ pub pure fn rev_each<T>(v: &r/[T], blk: fn(v: &r/T) -> bool) { * Return true to continue, false to break. */ #[inline(always)] -pub pure fn rev_eachi<T>(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) { +pub pure fn rev_eachi<T>(v: &r/[T], blk: &fn(i: uint, v: &r/T) -> bool) { let mut i = v.len(); while i > 0 { i -= 1; @@ -1431,7 +1431,7 @@ pub pure fn rev_eachi<T>(v: &r/[T], blk: fn(i: uint, v: &r/T) -> bool) { * Both vectors must have the same length */ #[inline] -pub pure fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { +pub pure fn each2<U, T>(v1: &[U], v2: &[T], f: &fn(u: &U, t: &T) -> bool) { fail_unless!(len(v1) == len(v2)); for uint::range(0u, len(v1)) |i| { if !f(&v1[i], &v2[i]) { @@ -1450,7 +1450,7 @@ pub pure fn each2<U, T>(v1: &[U], v2: &[T], f: fn(u: &U, t: &T) -> bool) { * The total number of permutations produced is `len(v)!`. If `v` contains * repeated elements, then some permutations are repeated. */ -pub pure fn each_permutation<T:Copy>(v: &[T], put: fn(ts: &[T]) -> bool) { +pub pure fn each_permutation<T:Copy>(v: &[T], put: &fn(ts: &[T]) -> bool) { let ln = len(v); if ln <= 1 { put(v); @@ -1497,7 +1497,7 @@ pub pure fn windowed<TT:Copy>(nn: uint, xx: &[TT]) -> ~[~[TT]] { #[inline(always)] pub pure fn as_imm_buf<T,U>(s: &[T], /* NB---this CANNOT be const, see below */ - f: fn(*T, uint) -> U) -> U { + f: &fn(*T, uint) -> U) -> U { // NB---Do not change the type of s to `&[const T]`. This is // unsound. The reason is that we are going to create immutable pointers @@ -1516,7 +1516,7 @@ pub pure fn as_imm_buf<T,U>(s: &[T], /// Similar to `as_imm_buf` but passing a `*const T` #[inline(always)] pub pure fn as_const_buf<T,U>(s: &[const T], - f: fn(*const T, uint) -> U) -> U { + f: &fn(*const T, uint) -> U) -> U { unsafe { let v : *(*const T,uint) = @@ -1529,7 +1529,7 @@ pub pure fn as_const_buf<T,U>(s: &[const T], /// Similar to `as_imm_buf` but passing a `*mut T` #[inline(always)] pub pure fn as_mut_buf<T,U>(s: &mut [T], - f: fn(*mut T, uint) -> U) -> U { + f: &fn(*mut T, uint) -> U) -> U { unsafe { let v : *(*mut T,uint) = @@ -1721,13 +1721,13 @@ pub trait ImmutableVector<T> { pure fn initn(&self, n: uint) -> &self/[T]; pure fn last(&self) -> &self/T; pure fn last_opt(&self) -> Option<&self/T>; - pure fn foldr<U: Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U; - pure fn map<U>(&self, f: fn(t: &T) -> U) -> ~[U]; - pure fn mapi<U>(&self, f: fn(uint, t: &T) -> U) -> ~[U]; - fn map_r<U>(&self, f: fn(x: &T) -> U) -> ~[U]; - pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool; - pure fn flat_map<U>(&self, f: fn(t: &T) -> ~[U]) -> ~[U]; - pure fn filter_mapped<U:Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U]; + pure fn foldr<U: Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U; + pure fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U]; + pure fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U]; + fn map_r<U>(&self, f: &fn(x: &T) -> U) -> ~[U]; + pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool; + pure fn flat_map<U>(&self, f: &fn(t: &T) -> ~[U]) -> ~[U]; + pure fn filter_mapped<U:Copy>(&self, f: &fn(t: &T) -> Option<U>) -> ~[U]; } /// Extension methods for vectors @@ -1772,24 +1772,24 @@ impl<T> ImmutableVector<T> for &self/[T] { /// Reduce a vector from right to left #[inline] - pure fn foldr<U:Copy>(&self, z: U, p: fn(t: &T, u: U) -> U) -> U { + pure fn foldr<U:Copy>(&self, z: U, p: &fn(t: &T, u: U) -> U) -> U { foldr(*self, z, p) } /// Apply a function to each element of a vector and return the results #[inline] - pure fn map<U>(&self, f: fn(t: &T) -> U) -> ~[U] { map(*self, f) } + pure fn map<U>(&self, f: &fn(t: &T) -> U) -> ~[U] { map(*self, f) } /** * Apply a function to the index and value of each element in the vector * and return the results */ - pure fn mapi<U>(&self, f: fn(uint, t: &T) -> U) -> ~[U] { + pure fn mapi<U>(&self, f: &fn(uint, t: &T) -> U) -> ~[U] { mapi(*self, f) } #[inline] - fn map_r<U>(&self, f: fn(x: &T) -> U) -> ~[U] { + fn map_r<U>(&self, f: &fn(x: &T) -> U) -> ~[U] { let mut r = ~[]; let mut i = 0; while i < self.len() { @@ -1804,7 +1804,7 @@ impl<T> ImmutableVector<T> for &self/[T] { * * If the vector is empty, true is returned. */ - pure fn alli(&self, f: fn(uint, t: &T) -> bool) -> bool { + pure fn alli(&self, f: &fn(uint, t: &T) -> bool) -> bool { alli(*self, f) } /** @@ -1812,7 +1812,7 @@ impl<T> ImmutableVector<T> for &self/[T] { * of each result vector */ #[inline] - pure fn flat_map<U>(&self, f: fn(t: &T) -> ~[U]) -> ~[U] { + pure fn flat_map<U>(&self, f: &fn(t: &T) -> ~[U]) -> ~[U] { flat_map(*self, f) } /** @@ -1822,15 +1822,15 @@ impl<T> ImmutableVector<T> for &self/[T] { * the resulting vector. */ #[inline] - pure fn filter_mapped<U:Copy>(&self, f: fn(t: &T) -> Option<U>) -> ~[U] { + pure fn filter_mapped<U:Copy>(&self, f: &fn(t: &T) -> Option<U>) -> ~[U] { filter_mapped(*self, f) } } pub trait ImmutableEqVector<T:Eq> { - pure fn position(&self, f: fn(t: &T) -> bool) -> Option<uint>; + pure fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint>; pure fn position_elem(&self, t: &T) -> Option<uint>; - pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option<uint>; + pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint>; pure fn rposition_elem(&self, t: &T) -> Option<uint>; } @@ -1843,7 +1843,7 @@ impl<T:Eq> ImmutableEqVector<T> for &self/[T] { * elements then none is returned. */ #[inline] - pure fn position(&self, f: fn(t: &T) -> bool) -> Option<uint> { + pure fn position(&self, f: &fn(t: &T) -> bool) -> Option<uint> { position(*self, f) } @@ -1861,7 +1861,7 @@ impl<T:Eq> ImmutableEqVector<T> for &self/[T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rposition(&self, f: fn(t: &T) -> bool) -> Option<uint> { + pure fn rposition(&self, f: &fn(t: &T) -> bool) -> Option<uint> { rposition(*self, f) } @@ -1873,9 +1873,9 @@ impl<T:Eq> ImmutableEqVector<T> for &self/[T] { } pub trait ImmutableCopyableVector<T> { - pure fn filtered(&self, f: fn(&T) -> bool) -> ~[T]; - pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T>; - pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]); + pure fn filtered(&self, f: &fn(&T) -> bool) -> ~[T]; + pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option<T>; + pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]); } /// Extension methods for vectors @@ -1888,7 +1888,7 @@ impl<T:Copy> ImmutableCopyableVector<T> for &self/[T] { * containing only those elements for which `f` returned true. */ #[inline] - pure fn filtered(&self, f: fn(t: &T) -> bool) -> ~[T] { + pure fn filtered(&self, f: &fn(t: &T) -> bool) -> ~[T] { filtered(*self, f) } @@ -1900,7 +1900,7 @@ impl<T:Copy> ImmutableCopyableVector<T> for &self/[T] { * returned. If `f` matches no elements then none is returned. */ #[inline] - pure fn rfind(&self, f: fn(t: &T) -> bool) -> Option<T> { + pure fn rfind(&self, f: &fn(t: &T) -> bool) -> Option<T> { rfind(*self, f) } @@ -1909,7 +1909,7 @@ impl<T:Copy> ImmutableCopyableVector<T> for &self/[T] { * those that do not. */ #[inline] - pure fn partitioned(&self, f: fn(&T) -> bool) -> (~[T], ~[T]) { + pure fn partitioned(&self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { partitioned(*self, f) } } @@ -1924,10 +1924,10 @@ pub trait OwnedVector<T> { fn remove(&mut self, i: uint) -> T; fn swap_remove(&mut self, index: uint) -> T; fn truncate(&mut self, newlen: uint); - fn retain(&mut self, f: pure fn(t: &T) -> bool); - fn consume(self, f: fn(uint, v: T)); - fn filter(self, f: fn(t: &T) -> bool) -> ~[T]; - fn partition(self, f: pure fn(&T) -> bool) -> (~[T], ~[T]); + fn retain(&mut self, f: &pure fn(t: &T) -> bool); + fn consume(self, f: &fn(uint, v: T)); + fn filter(self, f: &fn(t: &T) -> bool) -> ~[T]; + fn partition(self, f: &pure fn(&T) -> bool) -> (~[T], ~[T]); fn grow_fn(&mut self, n: uint, op: iter::InitOp<T>); } @@ -1978,17 +1978,17 @@ impl<T> OwnedVector<T> for ~[T] { } #[inline] - fn retain(&mut self, f: pure fn(t: &T) -> bool) { + fn retain(&mut self, f: &pure fn(t: &T) -> bool) { retain(self, f); } #[inline] - fn consume(self, f: fn(uint, v: T)) { + fn consume(self, f: &fn(uint, v: T)) { consume(self, f) } #[inline] - fn filter(self, f: fn(&T) -> bool) -> ~[T] { + fn filter(self, f: &fn(&T) -> bool) -> ~[T] { filter(self, f) } @@ -1997,7 +1997,7 @@ impl<T> OwnedVector<T> for ~[T] { * those that do not. */ #[inline] - fn partition(self, f: fn(&T) -> bool) -> (~[T], ~[T]) { + fn partition(self, f: &fn(&T) -> bool) -> (~[T], ~[T]) { partition(self, f) } @@ -2138,7 +2138,7 @@ pub mod raw { #[inline(always)] pub unsafe fn buf_as_slice<T,U>(p: *T, len: uint, - f: fn(v: &[T]) -> U) -> U { + f: &fn(v: &[T]) -> U) -> U { let pair = (p, len * sys::nonzero_size_of::<T>()); let v : *(&blk/[T]) = ::cast::reinterpret_cast(&addr_of(&pair)); @@ -2270,7 +2270,9 @@ pub mod bytes { impl<A> iter::BaseIter<A> for &self/[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pub pure fn each(&self, blk: &fn(v: &'self A) -> bool) { + each(*self, blk) + } #[inline(always)] pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } @@ -2278,7 +2280,7 @@ impl<A> iter::BaseIter<A> for &self/[A] { // FIXME(#4148): This should be redundant impl<A> iter::BaseIter<A> for ~[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } @@ -2286,31 +2288,31 @@ impl<A> iter::BaseIter<A> for ~[A] { // FIXME(#4148): This should be redundant impl<A> iter::BaseIter<A> for @[A] { #[inline(always)] - pure fn each(&self, blk: fn(v: &'self A) -> bool) { each(*self, blk) } + pure fn each(&self, blk: &fn(v: &'self A) -> bool) { each(*self, blk) } #[inline(always)] pure fn size_hint(&self) -> Option<uint> { Some(self.len()) } } impl<A> iter::ExtendedIter<A> for &self/[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint> { iter::position(self, f) } - pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2318,25 +2320,25 @@ impl<A> iter::ExtendedIter<A> for &self/[A] { // FIXME(#4148): This should be redundant impl<A> iter::ExtendedIter<A> for ~[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint> { iter::position(self, f) } - pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2344,25 +2346,25 @@ impl<A> iter::ExtendedIter<A> for ~[A] { // FIXME(#4148): This should be redundant impl<A> iter::ExtendedIter<A> for @[A] { - pub pure fn eachi(&self, blk: fn(uint, v: &A) -> bool) { + pub pure fn eachi(&self, blk: &fn(uint, v: &A) -> bool) { iter::eachi(self, blk) } - pub pure fn all(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn all(&self, blk: &fn(&A) -> bool) -> bool { iter::all(self, blk) } - pub pure fn any(&self, blk: fn(&A) -> bool) -> bool { + pub pure fn any(&self, blk: &fn(&A) -> bool) -> bool { iter::any(self, blk) } - pub pure fn foldl<B>(&self, b0: B, blk: fn(&B, &A) -> B) -> B { + pub pure fn foldl<B>(&self, b0: B, blk: &fn(&B, &A) -> B) -> B { iter::foldl(self, b0, blk) } - pub pure fn position(&self, f: fn(&A) -> bool) -> Option<uint> { + pub pure fn position(&self, f: &fn(&A) -> bool) -> Option<uint> { iter::position(self, f) } - pure fn map_to_vec<B>(&self, op: fn(&A) -> B) -> ~[B] { + pure fn map_to_vec<B>(&self, op: &fn(&A) -> B) -> ~[B] { iter::map_to_vec(self, op) } - pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: fn(&A) -> IB) + pure fn flat_map_to_vec<B,IB:BaseIter<B>>(&self, op: &fn(&A) -> IB) -> ~[B] { iter::flat_map_to_vec(self, op) } @@ -2386,33 +2388,33 @@ impl<A:Eq> iter::EqIter<A> for @[A] { } impl<A:Copy> iter::CopyableIter<A> for &self/[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option<A> { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option<A> { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl<A:Copy> iter::CopyableIter<A> for ~[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option<A> { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option<A> { iter::find(self, f) } } // FIXME(#4148): This should be redundant impl<A:Copy> iter::CopyableIter<A> for @[A] { - pure fn filter_to_vec(&self, pred: fn(&A) -> bool) -> ~[A] { + pure fn filter_to_vec(&self, pred: &fn(&A) -> bool) -> ~[A] { iter::filter_to_vec(self, pred) } pure fn to_vec(&self) -> ~[A] { iter::to_vec(self) } - pub pure fn find(&self, f: fn(&A) -> bool) -> Option<A> { + pub pure fn find(&self, f: &fn(&A) -> bool) -> Option<A> { iter::find(self, f) } } @@ -2435,7 +2437,7 @@ impl<A:Copy + Ord> iter::CopyableOrderedIter<A> for @[A] { } impl<A:Copy> iter::CopyableNonstrictIter<A> for &self/[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2446,7 +2448,7 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for &self/[A] { // FIXME(#4148): This should be redundant impl<A:Copy> iter::CopyableNonstrictIter<A> for ~[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } @@ -2457,7 +2459,7 @@ impl<A:Copy> iter::CopyableNonstrictIter<A> for ~[A] { // FIXME(#4148): This should be redundant impl<A:Copy> iter::CopyableNonstrictIter<A> for @[A] { - pure fn each_val(&const self, f: fn(A) -> bool) { + pure fn each_val(&const self, f: &fn(A) -> bool) { let mut i = 0; while i < self.len() { if !f(copy self[i]) { break; } |
