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 @@ -134,6 +134,22 @@ pub fn lookup_host(host: &str) -> io::Result<LookupHost> {
134
134
/// This function may perform a DNS query to resolve `addr` and may also inspect
135
135
/// system configuration to resolve the specified address. If the address
136
136
/// cannot be resolved, it is returned in string format.
137
+ ///
138
+ /// # Examples
139
+ ///
140
+ /// ```no_run
141
+ /// #![feature(lookup_addr)]
142
+ /// #![feature(ip_addr)]
143
+ ///
144
+ /// use std::net::{self, Ipv4Addr, IpAddr};
145
+ ///
146
+ /// let ip_addr = "8.8.8.8";
147
+ /// let addr: Ipv4Addr = ip_addr.parse().unwrap();
148
+ /// let hostname = net::lookup_addr(&IpAddr::V4(addr)).unwrap();
149
+ ///
150
+ /// println!("{} --> {}", ip_addr, hostname);
151
+ /// // Output: 8.8.8.8 --> google-public-dns-a.google.com
152
+ /// ```
137
153
#[ unstable( feature = "lookup_addr" , reason = "recent addition" ,
138
154
issue = "27705" ) ]
139
155
pub fn lookup_addr ( addr : & IpAddr ) -> io:: Result < String > {
You can’t perform that action at this time.
0 commit comments