Created
January 24, 2020 13:20
-
-
Save rust-play/ea970e4d3dede0ef9f554b55200e51e0 to your computer and use it in GitHub Desktop.
Code shared from the Rust Playground
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
use std::net; | |
fn main() { | |
let ip: Result<net::IpAddr, _> = "::1".parse(); | |
println!("{:?}", ip); | |
let addr = net::SocketAddr::new(ip.unwrap(), 9200); | |
println!("{:?}", addr); | |
println!("{}", addr); | |
println!("{}", addr.ip()); | |
println!("{}", addr.port()); | |
println!("----"); | |
let ip: Result<net::IpAddr, _> = "[::1]".parse(); | |
println!("{:?}", ip); | |
let addr = net::SocketAddr::new(ip.unwrap(), 9200); | |
println!("{:?}", addr); | |
println!("{}", addr); | |
println!("{}", addr.ip()); | |
println!("{}", addr.port()); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment