diff options
| author | bors <bors@rust-lang.org> | 2016-07-08 05:24:43 -0700 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2016-07-08 05:24:43 -0700 |
| commit | e7751e436ba4ff05dd844e330ee50afb7123e1fa (patch) | |
| tree | 56d348d5842edcb8ae3d528b512a17e481d847c8 /src/libstd | |
| parent | 3fa1cdf23cd28b8dc5c8ba1f626c5256713cc991 (diff) | |
| parent | 5389ccc0c198298fbc3f81915791788688012466 (diff) | |
| download | rust-e7751e436ba4ff05dd844e330ee50afb7123e1fa.tar.gz rust-e7751e436ba4ff05dd844e330ee50afb7123e1fa.zip | |
Auto merge of #34720 - Manishearth:rollup, r=Manishearth
Rollup of 9 pull requests - Successful merges: #34097, #34456, #34610, #34612, #34659, #34688, #34691, #34699, #34700 - Failed merges:
Diffstat (limited to 'src/libstd')
| -rw-r--r-- | src/libstd/io/error.rs | 24 | ||||
| -rw-r--r-- | src/libstd/path.rs | 14 | ||||
| -rw-r--r-- | src/libstd/sys/common/net.rs | 12 |
3 files changed, 47 insertions, 3 deletions
diff --git a/src/libstd/io/error.rs b/src/libstd/io/error.rs index e142c78569b..05ae8ed5b0b 100644 --- a/src/libstd/io/error.rs +++ b/src/libstd/io/error.rs @@ -214,6 +214,30 @@ impl Error { } /// Creates a new instance of an `Error` from a particular OS error code. + /// + /// # Examples + /// + /// On Linux: + /// + /// ``` + /// # if cfg!(target_os = "linux") { + /// use std::io; + /// + /// let error = io::Error::from_raw_os_error(98); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` + /// + /// On Windows: + /// + /// ``` + /// # if cfg!(windows) { + /// use std::io; + /// + /// let error = io::Error::from_raw_os_error(10048); + /// assert_eq!(error.kind(), io::ErrorKind::AddrInUse); + /// # } + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn from_raw_os_error(code: i32) -> Error { Error { repr: Repr::Os(code) } diff --git a/src/libstd/path.rs b/src/libstd/path.rs index ad4cdef6158..2d19561139b 100644 --- a/src/libstd/path.rs +++ b/src/libstd/path.rs @@ -1529,8 +1529,7 @@ impl Path { /// The final component of the path, if it is a normal file. /// - /// If the path terminates in `.`, `..`, or consists solely of a root of - /// prefix, `file_name` will return `None`. + /// If the path terminates in `..`, `file_name` will return `None`. /// /// # Examples /// @@ -1543,6 +1542,17 @@ impl Path { /// /// assert_eq!(Some(os_str), path.file_name()); /// ``` + /// + /// # Other examples + /// + /// ``` + /// use std::path::Path; + /// use std::ffi::OsStr; + /// + /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.").file_name()); + /// assert_eq!(Some(OsStr::new("foo.txt")), Path::new("foo.txt/.//").file_name()); + /// assert_eq!(None, Path::new("foo.txt/..").file_name()); + /// ``` #[stable(feature = "rust1", since = "1.0.0")] pub fn file_name(&self) -> Option<&OsStr> { self.components().next_back().and_then(|p| { diff --git a/src/libstd/sys/common/net.rs b/src/libstd/sys/common/net.rs index 274e495d70e..26925b12f93 100644 --- a/src/libstd/sys/common/net.rs +++ b/src/libstd/sys/common/net.rs @@ -152,9 +152,19 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> { init(); let c_host = CString::new(host)?; + let hints = c::addrinfo { + ai_flags: 0, + ai_family: 0, + ai_socktype: c::SOCK_STREAM, + ai_protocol: 0, + ai_addrlen: 0, + ai_addr: ptr::null_mut(), + ai_canonname: ptr::null_mut(), + ai_next: ptr::null_mut() + }; let mut res = ptr::null_mut(); unsafe { - cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), ptr::null(), + cvt_gai(c::getaddrinfo(c_host.as_ptr(), ptr::null(), &hints, &mut res))?; Ok(LookupHost { original: res, cur: res }) } |
