File tree 1 file changed +16
-0
lines changed
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> {
135
135
/// This function may perform a DNS query to resolve `addr` and may also inspect
136
136
/// system configuration to resolve the specified address. If the address
137
137
/// 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
+ /// ```
138
154
#[ unstable( feature = "lookup_addr" , reason = "recent addition" ,
139
155
issue = "27705" ) ]
140
156
#[ rustc_deprecated( reason = "ipaddr type is being deprecated" ,
You can’t perform that action at this time.
0 commit comments