Skip to content

doc: add example for std::net::lookup_addr #30188

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Dec 7, 2015
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 16 additions & 0 deletions src/libstd/net/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,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")]
pub fn lookup_addr(addr: &IpAddr) -> io::Result<String> {
Expand Down