Skip to content

Commit 081e3dd

Browse files
author
Eric Reed
committed
---
yaml --- r: 63703 b: refs/heads/snap-stage3 c: 87ecfb7 h: refs/heads/master i: 63701: cc6b150 63699: 937fea7 63695: a067daf v: v3
1 parent 50b16f0 commit 081e3dd

File tree

2 files changed

+10
-25
lines changed

2 files changed

+10
-25
lines changed

[refs]

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
---
22
refs/heads/master: 2d28d645422c1617be58c8ca7ad9a457264ca850
33
refs/heads/snap-stage1: e33de59e47c5076a89eadeb38f4934f58a3618a6
4-
refs/heads/snap-stage3: d0dc6970d8b8bb0e6cc358ec169daa70d99e1d15
4+
refs/heads/snap-stage3: 87ecfb74357b669308a6e337ebc766af8a03b554
55
refs/heads/try: 7b78b52e602bb3ea8174f9b2006bff3315f03ef9
66
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
77
refs/heads/ndm: f3868061cd7988080c30d6d5bf352a5a5fe2460b

branches/snap-stage3/src/libstd/rt/io/net/tcp.rs

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -18,15 +18,11 @@ use rt::rtio::{IoFactory, IoFactoryObject,
1818
RtioTcpStream, RtioTcpStreamObject};
1919
use rt::local::Local;
2020

21-
pub struct TcpStream {
22-
rtstream: ~RtioTcpStreamObject
23-
}
21+
pub struct TcpStream(~RtioTcpStreamObject);
2422

2523
impl TcpStream {
2624
fn new(s: ~RtioTcpStreamObject) -> TcpStream {
27-
TcpStream {
28-
rtstream: s
29-
}
25+
TcpStream(s)
3026
}
3127

3228
pub fn connect(addr: IpAddr) -> Option<TcpStream> {
@@ -38,22 +34,19 @@ impl TcpStream {
3834
};
3935

4036
match stream {
41-
Ok(s) => {
42-
Some(TcpStream::new(s))
43-
}
37+
Ok(s) => Some(TcpStream::new(s)),
4438
Err(ioerr) => {
4539
rtdebug!("failed to connect: %?", ioerr);
4640
io_error::cond.raise(ioerr);
47-
return None;
41+
None
4842
}
4943
}
5044
}
5145
}
5246

5347
impl Reader for TcpStream {
5448
fn read(&mut self, buf: &mut [u8]) -> Option<uint> {
55-
let bytes_read = self.rtstream.read(buf);
56-
match bytes_read {
49+
match (**self).read(buf) {
5750
Ok(read) => Some(read),
5851
Err(ioerr) => {
5952
// EOF is indicated by returning None
@@ -70,8 +63,7 @@ impl Reader for TcpStream {
7063

7164
impl Writer for TcpStream {
7265
fn write(&mut self, buf: &[u8]) {
73-
let res = self.rtstream.write(buf);
74-
match res {
66+
match (**self).write(buf) {
7567
Ok(_) => (),
7668
Err(ioerr) => {
7769
io_error::cond.raise(ioerr);
@@ -82,9 +74,7 @@ impl Writer for TcpStream {
8274
fn flush(&mut self) { fail!() }
8375
}
8476

85-
pub struct TcpListener {
86-
rtlistener: ~RtioTcpListenerObject,
87-
}
77+
pub struct TcpListener(~RtioTcpListenerObject);
8878

8979
impl TcpListener {
9080
pub fn bind(addr: IpAddr) -> Option<TcpListener> {
@@ -93,11 +83,7 @@ impl TcpListener {
9383
(*io).tcp_bind(addr)
9484
};
9585
match listener {
96-
Ok(l) => {
97-
Some(TcpListener {
98-
rtlistener: l
99-
})
100-
}
86+
Ok(l) => Some(TcpListener(l)),
10187
Err(ioerr) => {
10288
io_error::cond.raise(ioerr);
10389
return None;
@@ -108,8 +94,7 @@ impl TcpListener {
10894

10995
impl Listener<TcpStream> for TcpListener {
11096
fn accept(&mut self) -> Option<TcpStream> {
111-
let rtstream = self.rtlistener.accept();
112-
match rtstream {
97+
match (**self).accept() {
11398
Ok(s) => {
11499
Some(TcpStream::new(s))
115100
}

0 commit comments

Comments
 (0)