diff options
author | Liran Ringel <5730310+liranringel@users.noreply.github.com> | 2018-11-20 18:10:36 +0200 |
---|---|---|
committer | Toby Lawrence <tobz@users.noreply.github.com> | 2018-11-20 11:10:36 -0500 |
commit | 9b1a45cc6a15f5d2be17531dffc2f50d2b019646 (patch) | |
tree | da66c5c9574f2cd7ad11745e414fc34da2e35c6f /examples/echo-udp.rs | |
parent | 477fa5580aa3796f97e3e0eb1325d4690b3b4e96 (diff) |
tests: handle errors properly in examples (#748)
Diffstat (limited to 'examples/echo-udp.rs')
-rw-r--r-- | examples/echo-udp.rs | 9 |
1 files changed, 5 insertions, 4 deletions
diff --git a/examples/echo-udp.rs b/examples/echo-udp.rs index 89cc3d16..08a14563 100644 --- a/examples/echo-udp.rs +++ b/examples/echo-udp.rs @@ -50,12 +50,12 @@ impl Future for Server { } } -fn main() { +fn main() -> Result<(), Box<std::error::Error>> { let addr = env::args().nth(1).unwrap_or("127.0.0.1:8080".to_string()); - let addr = addr.parse::<SocketAddr>().unwrap(); + let addr = addr.parse::<SocketAddr>()?; - let socket = UdpSocket::bind(&addr).unwrap(); - println!("Listening on: {}", socket.local_addr().unwrap()); + let socket = UdpSocket::bind(&addr)?; + println!("Listening on: {}", socket.local_addr()?); let server = Server { socket: socket, @@ -70,4 +70,5 @@ fn main() { // // `tokio::run` spawns the task on the Tokio runtime and starts running. tokio::run(server.map_err(|e| println!("server error = {:?}", e))); + Ok(()) } |