File tree Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Expand file tree Collapse file tree 1 file changed +16
-0
lines changed Original file line number Diff line number Diff line change @@ -135,6 +135,22 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
135135/// This function may perform a DNS query to resolve `addr` and may also inspect
136136/// system configuration to resolve the specified address. If the address
137137/// cannot be resolved, it is returned in string format.
138+ ///
139+ /// # Examples
140+ ///
141+ /// ```no_run
142+ /// #![feature(lookup_addr)]
143+ /// #![feature(ip_addr)]
144+ ///
145+ /// use std::net::{self, Ipv4Addr, IpAddr};
146+ ///
147+ /// let ip_addr = "8.8.8.8";
148+ /// let addr: Ipv4Addr = ip_addr.parse().unwrap();
149+ /// let hostname = net::lookup_addr(&IpAddr::V4(addr)).unwrap();
150+ ///
151+ /// println!("{} --> {}", ip_addr, hostname);
152+ /// // Output: 8.8.8.8 --> google-public-dns-a.google.com
153+ /// ```
138154#[ unstable( feature = "lookup_addr" , reason = "recent addition" ,
139155 issue = "27705" ) ]
140156#[ rustc_deprecated( reason = "ipaddr type is being deprecated" ,
You can’t perform that action at this time.
0 commit comments