File tree Expand file tree Collapse file tree 2 files changed +12
-11
lines changed
branches/try/src/libstd/sys/windows Expand file tree Collapse file tree 2 files changed +12
-11
lines changed Original file line number Diff line number Diff line change 1
1
---
2
2
refs/heads/master: 6dbb0e86aec11050480beb76eade6fb805010ba7
3
3
refs/heads/snap-stage3: 235d77457d80b549dad3ac36d94f235208a1eafb
4
- refs/heads/try: a3fdf327e8bda2aaafd597f09c25b2192bb4a287
4
+ refs/heads/try: abb3a107e45b93ca5332ab11bfa6cc8d5a882fb4
5
5
refs/tags/release-0.1: 1f5c5126e96c79d22cb7862f75304136e204f105
6
6
refs/tags/release-0.2: c870d2dffb391e14efb05aa27898f1f6333a9596
7
7
refs/tags/release-0.3: b5f0d0f648d9a6153664837026ba1be43d3e2503
Original file line number Diff line number Diff line change @@ -61,27 +61,28 @@ fn last_error() -> io::Error {
61
61
}
62
62
63
63
/// Checks if the signed integer is the Windows constant `SOCKET_ERROR` (-1)
64
- /// and if so, returns the last error from the Windows socket interface. . This
64
+ /// and if so, returns the last error from the Windows socket interface. This
65
65
/// function must be called before another call to the socket API is made.
66
- pub fn cvt < T : One + Neg < Output =T > + PartialEq > ( t : T ) -> io:: Result < T > {
67
- let one: T = T :: one ( ) ;
68
- if t == -one {
66
+ pub fn cvt < T : One + PartialEq + Neg < Output =T > > ( t : T ) -> io:: Result < T > {
67
+ if t == -T :: one ( ) {
69
68
Err ( last_error ( ) )
70
69
} else {
71
70
Ok ( t)
72
71
}
73
72
}
74
73
75
- /// Provides the functionality of `cvt` for the return values of `getaddrinfo`
76
- /// and similar, meaning that they return an error if the return value is 0.
74
+ /// A variant of `cvt` for `getaddrinfo` which return 0 for a success.
77
75
pub fn cvt_gai ( err : c_int ) -> io:: Result < ( ) > {
78
- if err == 0 { return Ok ( ( ) ) }
79
- cvt ( err) . map ( |_| ( ) )
76
+ if err == 0 {
77
+ Ok ( ( ) )
78
+ } else {
79
+ Err ( last_error ( ) )
80
+ }
80
81
}
81
82
82
- /// Provides the functionality of `cvt` for a closure.
83
+ /// Just to provide the same interface as sys/unix/net.rs
83
84
pub fn cvt_r < T , F > ( mut f : F ) -> io:: Result < T >
84
- where F : FnMut ( ) -> T , T : One + Neg < Output =T > + PartialEq
85
+ where T : One + PartialEq + Neg < Output =T > , F : FnMut ( ) -> T
85
86
{
86
87
cvt ( f ( ) )
87
88
}
You can’t perform that action at this time.
0 commit comments