diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2014-05-05 18:56:44 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2014-05-06 23:12:54 -0700 |
| commit | 090040bf4037a094e50b03d79e4baf5cd89c912b (patch) | |
| tree | 27fa91d623889d59260d3db167abdfa8c4288849 /src/libstd/io | |
| parent | 24f6f26e633e50b5b59f9d0f6cca0b1e49e215d9 (diff) | |
| download | rust-090040bf4037a094e50b03d79e4baf5cd89c912b.tar.gz rust-090040bf4037a094e50b03d79e4baf5cd89c912b.zip | |
librustc: Remove `~EXPR`, `~TYPE`, and `~PAT` from the language, except
for `~str`/`~[]`. Note that `~self` still remains, since I forgot to add support for `Box<self>` before the snapshot. How to update your code: * Instead of `~EXPR`, you should write `box EXPR`. * Instead of `~TYPE`, you should write `Box<Type>`. * Instead of `~PATTERN`, you should write `box PATTERN`. [breaking-change]
Diffstat (limited to 'src/libstd/io')
| -rw-r--r-- | src/libstd/io/fs.rs | 7 | ||||
| -rw-r--r-- | src/libstd/io/mod.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/net/tcp.rs | 9 | ||||
| -rw-r--r-- | src/libstd/io/net/udp.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/net/unix.rs | 7 | ||||
| -rw-r--r-- | src/libstd/io/pipe.rs | 5 | ||||
| -rw-r--r-- | src/libstd/io/process.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/signal.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/stdio.rs | 20 | ||||
| -rw-r--r-- | src/libstd/io/timer.rs | 3 | ||||
| -rw-r--r-- | src/libstd/io/util.rs | 10 |
11 files changed, 43 insertions, 32 deletions
diff --git a/src/libstd/io/fs.rs b/src/libstd/io/fs.rs index 6d48b9eee35..3f66ecd5db3 100644 --- a/src/libstd/io/fs.rs +++ b/src/libstd/io/fs.rs @@ -55,11 +55,12 @@ use container::Container; use iter::Iterator; use kinds::Send; use super::{Reader, Writer, Seek}; -use super::{SeekStyle, Read, Write, Open, IoError, Truncate, - FileMode, FileAccess, FileStat, IoResult, FilePermission}; +use super::{SeekStyle, Read, Write, Open, IoError, Truncate}; +use super::{FileMode, FileAccess, FileStat, IoResult, FilePermission}; use rt::rtio::{RtioFileStream, IoFactory, LocalIo}; use io; use option::{Some, None, Option}; +use owned::Box; use result::{Ok, Err}; use path; use path::{Path, GenericPath}; @@ -78,7 +79,7 @@ use vec::Vec; /// configured at creation time, via the `FileAccess` parameter to /// `File::open_mode()`. pub struct File { - fd: ~RtioFileStream:Send, + fd: Box<RtioFileStream:Send>, path: Path, last_nread: int, } diff --git a/src/libstd/io/mod.rs b/src/libstd/io/mod.rs index ff276d02028..59a8c6f3439 100644 --- a/src/libstd/io/mod.rs +++ b/src/libstd/io/mod.rs @@ -227,6 +227,7 @@ use libc; use ops::{BitOr, BitAnd, Sub}; use os; use option::{Option, Some, None}; +use owned::Box; use path::Path; use result::{Ok, Err, Result}; use str::StrSlice; @@ -811,7 +812,7 @@ pub trait Reader { } } -impl Reader for ~Reader { +impl Reader for Box<Reader> { fn read(&mut self, buf: &mut [u8]) -> IoResult<uint> { self.read(buf) } } @@ -1052,7 +1053,7 @@ pub trait Writer { } } -impl Writer for ~Writer { +impl Writer for Box<Writer> { fn write(&mut self, buf: &[u8]) -> IoResult<()> { self.write(buf) } fn flush(&mut self) -> IoResult<()> { self.flush() } } diff --git a/src/libstd/io/net/tcp.rs b/src/libstd/io/net/tcp.rs index 0619c89aac1..69ccd2d28c9 100644 --- a/src/libstd/io/net/tcp.rs +++ b/src/libstd/io/net/tcp.rs @@ -23,6 +23,7 @@ use io::net::ip::SocketAddr; use io::{Reader, Writer, Listener, Acceptor}; use kinds::Send; use option::{None, Some, Option}; +use owned::Box; use rt::rtio::{IoFactory, LocalIo, RtioSocket, RtioTcpListener}; use rt::rtio::{RtioTcpAcceptor, RtioTcpStream}; @@ -45,11 +46,11 @@ use rt::rtio::{RtioTcpAcceptor, RtioTcpStream}; /// drop(stream); // close the connection /// ``` pub struct TcpStream { - obj: ~RtioTcpStream:Send + obj: Box<RtioTcpStream:Send>, } impl TcpStream { - fn new(s: ~RtioTcpStream:Send) -> TcpStream { + fn new(s: Box<RtioTcpStream:Send>) -> TcpStream { TcpStream { obj: s } } @@ -148,7 +149,7 @@ impl Writer for TcpStream { /// # } /// ``` pub struct TcpListener { - obj: ~RtioTcpListener:Send + obj: Box<RtioTcpListener:Send>, } impl TcpListener { @@ -181,7 +182,7 @@ impl Listener<TcpStream, TcpAcceptor> for TcpListener { /// a `TcpListener`'s `listen` method, and this object can be used to accept new /// `TcpStream` instances. pub struct TcpAcceptor { - obj: ~RtioTcpAcceptor:Send + obj: Box<RtioTcpAcceptor:Send>, } impl TcpAcceptor { diff --git a/src/libstd/io/net/udp.rs b/src/libstd/io/net/udp.rs index 184069bab33..2cc0f853e35 100644 --- a/src/libstd/io/net/udp.rs +++ b/src/libstd/io/net/udp.rs @@ -19,6 +19,7 @@ use clone::Clone; use io::net::ip::SocketAddr; use io::{Reader, Writer, IoResult}; use kinds::Send; +use owned::Box; use result::{Ok, Err}; use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, LocalIo}; @@ -54,7 +55,7 @@ use rt::rtio::{RtioSocket, RtioUdpSocket, IoFactory, LocalIo}; /// drop(socket); // close the socket /// ``` pub struct UdpSocket { - obj: ~RtioUdpSocket:Send + obj: Box<RtioUdpSocket:Send>, } impl UdpSocket { diff --git a/src/libstd/io/net/unix.rs b/src/libstd/io/net/unix.rs index b75b797e974..f6e985dc278 100644 --- a/src/libstd/io/net/unix.rs +++ b/src/libstd/io/net/unix.rs @@ -31,6 +31,7 @@ use clone::Clone; use io::pipe::PipeStream; use io::{Listener, Acceptor, Reader, Writer, IoResult}; use kinds::Send; +use owned::Box; use rt::rtio::{IoFactory, LocalIo, RtioUnixListener}; use rt::rtio::{RtioUnixAcceptor, RtioPipe}; @@ -40,7 +41,7 @@ pub struct UnixStream { } impl UnixStream { - fn new(obj: ~RtioPipe:Send) -> UnixStream { + fn new(obj: Box<RtioPipe:Send>) -> UnixStream { UnixStream { obj: PipeStream::new(obj) } } @@ -107,7 +108,7 @@ impl Writer for UnixStream { /// A value that can listen for incoming named pipe connection requests. pub struct UnixListener { /// The internal, opaque runtime Unix listener. - obj: ~RtioUnixListener:Send, + obj: Box<RtioUnixListener:Send>, } impl UnixListener { @@ -149,7 +150,7 @@ impl Listener<UnixStream, UnixAcceptor> for UnixListener { /// A value that can accept named pipe connections, returned from `listen()`. pub struct UnixAcceptor { /// The internal, opaque runtime Unix acceptor. - obj: ~RtioUnixAcceptor:Send, + obj: Box<RtioUnixAcceptor:Send>, } impl UnixAcceptor { diff --git a/src/libstd/io/pipe.rs b/src/libstd/io/pipe.rs index 77a97f4e259..fbb0d5bc8d8 100644 --- a/src/libstd/io/pipe.rs +++ b/src/libstd/io/pipe.rs @@ -18,12 +18,13 @@ use prelude::*; use io::IoResult; use libc; +use owned::Box; use rt::rtio::{RtioPipe, LocalIo}; /// A synchronous, in-memory pipe. pub struct PipeStream { /// The internal, opaque runtime pipe object. - obj: ~RtioPipe:Send, + obj: Box<RtioPipe:Send>, } impl PipeStream { @@ -54,7 +55,7 @@ impl PipeStream { } #[doc(hidden)] - pub fn new(inner: ~RtioPipe:Send) -> PipeStream { + pub fn new(inner: Box<RtioPipe:Send>) -> PipeStream { PipeStream { obj: inner } } } diff --git a/src/libstd/io/process.rs b/src/libstd/io/process.rs index b89e3ec3c77..1471a049bf3 100644 --- a/src/libstd/io/process.rs +++ b/src/libstd/io/process.rs @@ -17,6 +17,7 @@ use io::IoResult; use io; use libc; use mem; +use owned::Box; use rt::rtio::{RtioProcess, IoFactory, LocalIo}; /// Signal a process to exit, without forcibly killing it. Corresponds to @@ -52,7 +53,7 @@ use rt::rtio::{RtioProcess, IoFactory, LocalIo}; /// assert!(child.wait().success()); /// ``` pub struct Process { - handle: ~RtioProcess:Send, + handle: Box<RtioProcess:Send>, /// Handle to the child's stdin, if the `stdin` field of this process's /// `ProcessConfig` was `CreatePipe`. By default, this handle is `Some`. diff --git a/src/libstd/io/signal.rs b/src/libstd/io/signal.rs index e7dae59acb8..4d294e84070 100644 --- a/src/libstd/io/signal.rs +++ b/src/libstd/io/signal.rs @@ -26,6 +26,7 @@ use iter::Iterator; use kinds::Send; use mem::drop; use option::{Some, None}; +use owned::Box; use result::{Ok, Err}; use rt::rtio::{IoFactory, LocalIo, RtioSignal}; use slice::ImmutableVector; @@ -81,7 +82,7 @@ pub enum Signum { /// ``` pub struct Listener { /// A map from signums to handles to keep the handles in memory - handles: Vec<(Signum, ~RtioSignal:Send)>, + handles: Vec<(Signum, Box<RtioSignal:Send>)>, /// This is where all the handles send signums, which are received by /// the clients from the receiver. tx: Sender<Signum>, diff --git a/src/libstd/io/stdio.rs b/src/libstd/io/stdio.rs index 7cb58e1ea48..613e9f027a4 100644 --- a/src/libstd/io/stdio.rs +++ b/src/libstd/io/stdio.rs @@ -34,6 +34,7 @@ use libc; use kinds::Send; use mem::replace; use option::{Option, Some, None}; +use owned::Box; use prelude::drop; use result::{Ok, Err}; use rt; @@ -71,8 +72,8 @@ use str::StrSlice; // tl;dr; TTY works on everything but when windows stdout is redirected, in that // case pipe also doesn't work, but magically file does! enum StdSource { - TTY(~RtioTTY:Send), - File(~RtioFileStream:Send), + TTY(Box<RtioTTY:Send>), + File(Box<RtioFileStream:Send>), } fn src<T>(fd: libc::c_int, readable: bool, f: |StdSource| -> T) -> T { @@ -153,10 +154,9 @@ pub fn stderr_raw() -> StdWriter { src(libc::STDERR_FILENO, false, |src| StdWriter { inner: src }) } -fn reset_helper(w: ~Writer:Send, - f: |&mut Task, ~Writer:Send| -> Option<~Writer:Send>) - -> Option<~Writer:Send> -{ +fn reset_helper(w: Box<Writer:Send>, + f: |&mut Task, Box<Writer:Send>| -> Option<Box<Writer:Send>>) + -> Option<Box<Writer:Send>> { let mut t = Local::borrow(None::<Task>); // Be sure to flush any pending output from the writer match f(&mut *t, w) { @@ -178,7 +178,7 @@ fn reset_helper(w: ~Writer:Send, /// /// Note that this does not need to be called for all new tasks; the default /// output handle is to the process's stdout stream. -pub fn set_stdout(stdout: ~Writer:Send) -> Option<~Writer:Send> { +pub fn set_stdout(stdout: Box<Writer:Send>) -> Option<Box<Writer:Send>> { reset_helper(stdout, |t, w| replace(&mut t.stdout, Some(w))) } @@ -190,7 +190,7 @@ pub fn set_stdout(stdout: ~Writer:Send) -> Option<~Writer:Send> { /// /// Note that this does not need to be called for all new tasks; the default /// output handle is to the process's stderr stream. -pub fn set_stderr(stderr: ~Writer:Send) -> Option<~Writer:Send> { +pub fn set_stderr(stderr: Box<Writer:Send>) -> Option<Box<Writer:Send>> { reset_helper(stderr, |t, w| replace(&mut t.stderr, Some(w))) } @@ -205,7 +205,7 @@ pub fn set_stderr(stderr: ~Writer:Send) -> Option<~Writer:Send> { // }) // }) fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) { - let task: Option<~Task> = Local::try_take(); + let task: Option<Box<Task>> = Local::try_take(); let result = match task { Some(mut task) => { // Printing may run arbitrary code, so ensure that the task is in @@ -216,7 +216,7 @@ fn with_task_stdout(f: |&mut Writer| -> IoResult<()> ) { Local::put(task); if my_stdout.is_none() { - my_stdout = Some(box stdout() as ~Writer:Send); + my_stdout = Some(box stdout() as Box<Writer:Send>); } let ret = f(*my_stdout.get_mut_ref()); diff --git a/src/libstd/io/timer.rs b/src/libstd/io/timer.rs index 1ca36df968c..96c4083e7ed 100644 --- a/src/libstd/io/timer.rs +++ b/src/libstd/io/timer.rs @@ -20,6 +20,7 @@ and create receivers which will receive notifications after a period of time. use comm::Receiver; use io::IoResult; use kinds::Send; +use owned::Box; use rt::rtio::{IoFactory, LocalIo, RtioTimer}; /// A synchronous timer object @@ -63,7 +64,7 @@ use rt::rtio::{IoFactory, LocalIo, RtioTimer}; /// # } /// ``` pub struct Timer { - obj: ~RtioTimer:Send, + obj: Box<RtioTimer:Send>, } /// Sleep the current task for `msecs` milliseconds. diff --git a/src/libstd/io/util.rs b/src/libstd/io/util.rs index 5cae79d371f..b2e6b27caab 100644 --- a/src/libstd/io/util.rs +++ b/src/libstd/io/util.rs @@ -13,6 +13,7 @@ use prelude::*; use cmp; use io; +use owned::Box; use slice::bytes::MutableByteVector; /// Wraps a `Reader`, limiting the number of bytes that can be read from it. @@ -85,12 +86,12 @@ impl Reader for NullReader { /// A `Writer` which multiplexes writes to a set of `Writers`. pub struct MultiWriter { - writers: Vec<~Writer> + writers: Vec<Box<Writer>> } impl MultiWriter { /// Creates a new `MultiWriter` - pub fn new(writers: Vec<~Writer>) -> MultiWriter { + pub fn new(writers: Vec<Box<Writer>>) -> MultiWriter { MultiWriter { writers: writers } } } @@ -199,6 +200,7 @@ pub fn copy<R: Reader, W: Writer>(r: &mut R, w: &mut W) -> io::IoResult<()> { mod test { use io; use io::{MemReader, MemWriter}; + use owned::Box; use super::*; use prelude::*; @@ -273,8 +275,8 @@ mod test { } } - let mut multi = MultiWriter::new(vec!(box TestWriter as ~Writer, - box TestWriter as ~Writer)); + let mut multi = MultiWriter::new(vec!(box TestWriter as Box<Writer>, + box TestWriter as Box<Writer>)); multi.write([1, 2, 3]).unwrap(); assert_eq!(2, unsafe { writes }); assert_eq!(0, unsafe { flushes }); |
