about summary refs log tree commit diff
path: root/src/libstd/net
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2015-12-07 07:11:19 +0000
committerbors <bors@rust-lang.org>2015-12-07 07:11:19 +0000
commit7b77f67d1942620d550f0067c92d781c623aef58 (patch)
tree791f6a4abb95b114fb6aeec2e1a5659b1b42288b /src/libstd/net
parente819d8aa3cd2319fa57e7336e167069ef7002d6a (diff)
parent8569ef25913f7ed2410e348eced31e48c04258b7 (diff)
downloadrust-7b77f67d1942620d550f0067c92d781c623aef58.tar.gz
rust-7b77f67d1942620d550f0067c92d781c623aef58.zip
Auto merge of #30188 - tshepang:lookup_addr-example, r=alexcrichton
Diffstat (limited to 'src/libstd/net')
-rw-r--r--src/libstd/net/mod.rs16
1 files changed, 16 insertions, 0 deletions
diff --git a/src/libstd/net/mod.rs b/src/libstd/net/mod.rs
index 6bbbabfc269..545302b8393 100644
--- a/src/libstd/net/mod.rs
+++ b/src/libstd/net/mod.rs
@@ -135,6 +135,22 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
 /// This function may perform a DNS query to resolve `addr` and may also inspect
 /// system configuration to resolve the specified address. If the address
 /// cannot be resolved, it is returned in string format.
+///
+/// # Examples
+///
+/// ```no_run
+/// #![feature(lookup_addr)]
+/// #![feature(ip_addr)]
+///
+/// use std::net::{self, Ipv4Addr, IpAddr};
+///
+/// let ip_addr = "8.8.8.8";
+/// let addr: Ipv4Addr = ip_addr.parse().unwrap();
+/// let hostname = net::lookup_addr(&IpAddr::V4(addr)).unwrap();
+///
+/// println!("{} --> {}", ip_addr, hostname);
+/// // Output: 8.8.8.8 --> google-public-dns-a.google.com
+/// ```
 #[unstable(feature = "lookup_addr", reason = "recent addition",
            issue = "27705")]
 #[rustc_deprecated(reason = "ipaddr type is being deprecated",