about summary refs log tree commit diff
path: root/src/libstd/io
diff options
context:
space:
mode:
authorPatrick Walton <pcwalton@mimiga.net>2013-11-18 21:15:42 -0800
committerPatrick Walton <pcwalton@mimiga.net>2013-11-19 12:40:19 -0800
commit1946265e1a1a32eb922846f314657a4aa7eb1d23 (patch)
tree4b83f81bf1b265933a13605d9d35eab67a34ea8d /src/libstd/io
parenteef913b290f668b4f131ead5be65a1615616426b (diff)
downloadrust-1946265e1a1a32eb922846f314657a4aa7eb1d23.tar.gz
rust-1946265e1a1a32eb922846f314657a4aa7eb1d23.zip
libstd: Change all uses of `&fn(A)->B` over to `|A|->B` in libstd
Diffstat (limited to 'src/libstd/io')
-rw-r--r--src/libstd/io/extensions.rs6
-rw-r--r--src/libstd/io/fs.rs4
-rw-r--r--src/libstd/io/mem.rs2
-rw-r--r--src/libstd/io/mod.rs4
-rw-r--r--src/libstd/io/native/file.rs2
-rw-r--r--src/libstd/io/native/process.rs8
-rw-r--r--src/libstd/io/net/ip.rs23
-rw-r--r--src/libstd/io/net/udp.rs4
-rw-r--r--src/libstd/io/stdio.rs4
9 files changed, 31 insertions, 26 deletions
diff --git a/src/libstd/io/extensions.rs b/src/libstd/io/extensions.rs
index ebda2618dcf..5eb2e72e96b 100644
--- a/src/libstd/io/extensions.rs
+++ b/src/libstd/io/extensions.rs
@@ -54,8 +54,7 @@ impl<'self, R: Reader> Iterator<u8> for ByteIterator<R> {
     }
 }
 
-pub fn u64_to_le_bytes<T>(n: u64, size: uint,
-                          f: &fn(v: &[u8]) -> T) -> T {
+pub fn u64_to_le_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
     assert!(size <= 8u);
     match size {
       1u => f(&[n as u8]),
@@ -88,8 +87,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 {
+pub fn u64_to_be_bytes<T>(n: u64, size: uint, f: |v: &[u8]| -> T) -> T {
     assert!(size <= 8u);
     match size {
       1u => f(&[n as u8]),
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs
index cc3f8bacb24..930f58ef33f 100644
--- a/src/libstd/io/fs.rs
+++ b/src/libstd/io/fs.rs
@@ -75,7 +75,7 @@ pub struct File {
     priv last_nread: int,
 }
 
-fn io_raise<T>(f: &fn(io: &mut IoFactory) -> Result<T, IoError>) -> Option<T> {
+fn io_raise<T>(f: |io: &mut IoFactory| -> Result<T, IoError>) -> Option<T> {
     do with_local_io |io| {
         match f(io) {
             Ok(t) => Some(t),
@@ -499,7 +499,7 @@ pub fn rmdir(path: &Path) {
 ///     use std::io::fs;
 ///
 ///     // one possible implementation of fs::walk_dir only visiting files
-///     fn visit_dirs(dir: &Path, cb: &fn(&Path)) {
+///     fn visit_dirs(dir: &Path, cb: |&Path|) {
 ///         if dir.is_dir() {
 ///             let contents = fs::readdir(dir).unwrap();
 ///             for entry in contents.iter() {
diff --git a/src/libstd/io/mem.rs b/src/libstd/io/mem.rs
index 4b9c5ca5d4a..decdfb60bfb 100644
--- a/src/libstd/io/mem.rs
+++ b/src/libstd/io/mem.rs
@@ -240,7 +240,7 @@ impl<'self> Buffer for BufReader<'self> {
 
 ///Calls a function with a MemWriter and returns
 ///the writer's stored vector.
-pub fn with_mem_writer(writeFn:&fn(&mut MemWriter)) -> ~[u8] {
+pub fn with_mem_writer(writeFn: |&mut MemWriter|) -> ~[u8] {
     let mut writer = MemWriter::new();
     writeFn(&mut writer);
     writer.inner()
diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs
index c56189dbb2b..1d0fef48890 100644
--- a/src/libstd/io/mod.rs
+++ b/src/libstd/io/mod.rs
@@ -394,7 +394,7 @@ condition! {
 
 /// Helper for wrapper calls where you want to
 /// ignore any io_errors that might be raised
-pub fn ignore_io_error<T>(cb: &fn() -> T) -> T {
+pub fn ignore_io_error<T>(cb: || -> T) -> T {
     do io_error::cond.trap(|_| {
         // just swallow the error.. downstream users
         // who can make a decision based on a None result
@@ -407,7 +407,7 @@ pub fn ignore_io_error<T>(cb: &fn() -> T) -> T {
 /// Helper for catching an I/O error and wrapping it in a Result object. The
 /// return result will be the last I/O error that happened or the result of the
 /// closure if no error occurred.
-pub fn result<T>(cb: &fn() -> T) -> Result<T, IoError> {
+pub fn result<T>(cb: || -> T) -> Result<T, IoError> {
     let mut err = None;
     let ret = io_error::cond.trap(|e| {
         if err.is_none() {
diff --git a/src/libstd/io/native/file.rs b/src/libstd/io/native/file.rs
index b2cb8f735cf..abaeab609aa 100644
--- a/src/libstd/io/native/file.rs
+++ b/src/libstd/io/native/file.rs
@@ -33,7 +33,7 @@ use vec;
 #[cfg(windows)] use ptr;
 #[cfg(windows)] use str;
 
-fn keep_going(data: &[u8], f: &fn(*u8, uint) -> i64) -> i64 {
+fn keep_going(data: &[u8], f: |*u8, uint| -> i64) -> i64 {
     #[cfg(windows)] static eintr: int = 0; // doesn't matter
     #[cfg(not(windows))] static eintr: int = libc::EINTR as int;
 
diff --git a/src/libstd/io/native/process.rs b/src/libstd/io/native/process.rs
index 71c6ce78a1e..6aa3ae65fc9 100644
--- a/src/libstd/io/native/process.rs
+++ b/src/libstd/io/native/process.rs
@@ -432,7 +432,7 @@ fn spawn_process_os(prog: &str, args: &[~str],
 }
 
 #[cfg(unix)]
-fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
+fn with_argv<T>(prog: &str, args: &[~str], cb: |**libc::c_char| -> T) -> T {
     use vec;
 
     // We can't directly convert `str`s into `*char`s, as someone needs to hold
@@ -460,7 +460,7 @@ fn with_argv<T>(prog: &str, args: &[~str], cb: &fn(**libc::c_char) -> T) -> T {
 }
 
 #[cfg(unix)]
-fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
+fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*c_void| -> T) -> T {
     use vec;
 
     // On posixy systems we can pass a char** for envp, which is a
@@ -490,7 +490,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*c_void) -> T) -> T {
 }
 
 #[cfg(windows)]
-fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
+fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: |*mut 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.
@@ -514,7 +514,7 @@ fn with_envp<T>(env: Option<~[(~str, ~str)]>, cb: &fn(*mut c_void) -> T) -> T {
     }
 }
 
-fn with_dirp<T>(d: Option<&Path>, cb: &fn(*libc::c_char) -> T) -> T {
+fn with_dirp<T>(d: Option<&Path>, cb: |*libc::c_char| -> T) -> T {
     match d {
       Some(dir) => dir.with_c_str(|buf| cb(buf)),
       None => cb(ptr::null())
diff --git a/src/libstd/io/net/ip.rs b/src/libstd/io/net/ip.rs
index 07240a4a509..9c63108beef 100644
--- a/src/libstd/io/net/ip.rs
+++ b/src/libstd/io/net/ip.rs
@@ -81,7 +81,8 @@ impl<'self> Parser<'self> {
     }
 
     // Commit only if parser returns Some
-    fn read_atomically<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
+    fn read_atomically<T>(&mut self, cb: |&mut Parser| -> Option<T>)
+                       -> Option<T> {
         let pos = self.pos;
         let r = cb(self);
         if r.is_none() {
@@ -91,14 +92,16 @@ impl<'self> Parser<'self> {
     }
 
     // Commit only if parser read till EOF
-    fn read_till_eof<T>(&mut self, cb: &fn(&mut Parser) -> Option<T>) -> Option<T> {
+    fn read_till_eof<T>(&mut self, cb: |&mut Parser| -> Option<T>)
+                     -> Option<T> {
         do self.read_atomically |p| {
             cb(p).filtered(|_| p.is_eof())
         }
     }
 
     // Return result of first successful parser
-    fn read_or<T>(&mut self, parsers: &[&fn(&mut Parser) -> Option<T>]) -> Option<T> {
+    fn read_or<T>(&mut self, parsers: &[|&mut Parser| -> Option<T>])
+               -> Option<T> {
         for pf in parsers.iter() {
             match self.read_atomically(|p: &mut Parser| (*pf)(p)) {
                 Some(r) => return Some(r),
@@ -109,12 +112,14 @@ impl<'self> Parser<'self> {
     }
 
     // Apply 3 parsers sequentially
-    fn read_seq_3<A, B, C>(&mut self,
-            pa: &fn(&mut Parser) -> Option<A>,
-            pb: &fn(&mut Parser) -> Option<B>,
-            pc: &fn(&mut Parser) -> Option<C>
-        ) -> Option<(A, B, C)>
-    {
+    fn read_seq_3<A,
+                  B,
+                  C>(
+                  &mut self,
+                  pa: |&mut Parser| -> Option<A>,
+                  pb: |&mut Parser| -> Option<B>,
+                  pc: |&mut Parser| -> Option<C>)
+                  -> Option<(A, B, C)> {
         do self.read_atomically |p| {
             let a = pa(p);
             let b = if a.is_some() { pb(p) } else { None };
diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs
index 1a2245ac442..b8cdbfc25cb 100644
--- a/src/libstd/io/net/udp.rs
+++ b/src/libstd/io/net/udp.rs
@@ -74,7 +74,9 @@ pub struct UdpStream {
 }
 
 impl UdpStream {
-    pub fn as_socket<T>(&mut self, f: &fn(&mut UdpSocket) -> T) -> T { f(&mut self.socket) }
+    pub fn as_socket<T>(&mut self, f: |&mut UdpSocket| -> T) -> T {
+        f(&mut self.socket)
+    }
 
     pub fn disconnect(self) -> UdpSocket { self.socket }
 }
diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs
index 49cac428cb2..1362d702f1c 100644
--- a/src/libstd/io/stdio.rs
+++ b/src/libstd/io/stdio.rs
@@ -69,7 +69,7 @@ enum StdSource {
     File(~RtioFileStream),
 }
 
-fn src<T>(fd: libc::c_int, readable: bool, f: &fn(StdSource) -> T) -> T {
+fn src<T>(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T {
     do with_local_io |io| {
         let fd = unsafe { libc::dup(fd) };
         match io.tty_open(fd, readable) {
@@ -121,7 +121,7 @@ pub fn stderr() -> StdWriter {
 //          // io1 aliases io2
 //      }
 //  }
-fn with_task_stdout(f: &fn(&mut Writer)) {
+fn with_task_stdout(f: |&mut Writer|) {
     use rt::local::Local;
     use rt::task::Task;