Skip to content

Commit e5d21b9

Browse files
committed
core::rt: Make I/O constructors return Option instead of Result
For consistency, for all I/O calls, inspecting the error can be done with the io_error condition.
1 parent d0786fd commit e5d21b9

File tree

4 files changed

+7
-7
lines changed

4 files changed

+7
-7
lines changed

src/libcore/rt/io/file.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ impl FileStream {
4242
pub fn open<P: PathLike>(_path: &P,
4343
_mode: FileMode,
4444
_access: FileAccess
45-
) -> Result<FileStream, IoError> {
45+
) -> Option<FileStream> {
4646
fail!()
4747
}
4848
}

src/libcore/rt/io/net/tcp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::ip::IpAddr;
1616
pub struct TcpStream;
1717

1818
impl TcpStream {
19-
pub fn connect(_addr: IpAddr) -> Result<TcpStream, IoError> {
19+
pub fn connect(_addr: IpAddr) -> Option<TcpStream> {
2020
fail!()
2121
}
2222
}
@@ -40,7 +40,7 @@ impl Close for TcpStream {
4040
pub struct TcpListener;
4141

4242
impl TcpListener {
43-
pub fn bind(_addr: IpAddr) -> Result<TcpListener, IoError> {
43+
pub fn bind(_addr: IpAddr) -> Option<TcpListener> {
4444
fail!()
4545
}
4646
}

src/libcore/rt/io/net/udp.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::ip::IpAddr;
1616
pub struct UdpStream;
1717

1818
impl UdpStream {
19-
pub fn connect(_addr: IpAddr) -> Result<UdpStream, IoError> {
19+
pub fn connect(_addr: IpAddr) -> Option<UdpStream> {
2020
fail!()
2121
}
2222
}
@@ -40,7 +40,7 @@ impl Close for UdpStream {
4040
pub struct UdpListener;
4141

4242
impl UdpListener {
43-
pub fn bind(_addr: IpAddr) -> Result<UdpListener, IoError> {
43+
pub fn bind(_addr: IpAddr) -> Option<UdpListener> {
4444
fail!()
4545
}
4646
}

src/libcore/rt/io/net/unix.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ use super::super::support::PathLike;
1616
pub struct UnixStream;
1717

1818
impl UnixStream {
19-
pub fn connect<P: PathLike>(_path: &P) -> Result<UnixStream, IoError> {
19+
pub fn connect<P: PathLike>(_path: &P) -> Option<UnixStream> {
2020
fail!()
2121
}
2222
}
@@ -40,7 +40,7 @@ impl Close for UnixStream {
4040
pub struct UnixListener;
4141

4242
impl UnixListener {
43-
pub fn bind<P: PathLike>(_path: &P) -> Result<UnixListener, IoError> {
43+
pub fn bind<P: PathLike>(_path: &P) -> Option<UnixListener> {
4444
fail!()
4545
}
4646
}

0 commit comments

Comments
 (0)