summaryrefslogtreecommitdiffstats
path: root/examples/udp-codec.rs
diff options
context:
space:
mode:
authorLiran Ringel <5730310+liranringel@users.noreply.github.com>2018-11-20 18:10:36 +0200
committerToby Lawrence <tobz@users.noreply.github.com>2018-11-20 11:10:36 -0500
commit9b1a45cc6a15f5d2be17531dffc2f50d2b019646 (patch)
treeda66c5c9574f2cd7ad11745e414fc34da2e35c6f /examples/udp-codec.rs
parent477fa5580aa3796f97e3e0eb1325d4690b3b4e96 (diff)
tests: handle errors properly in examples (#748)
Diffstat (limited to 'examples/udp-codec.rs')
-rw-r--r--examples/udp-codec.rs11
1 files changed, 6 insertions, 5 deletions
diff --git a/examples/udp-codec.rs b/examples/udp-codec.rs
index b273a360..837266ac 100644
--- a/examples/udp-codec.rs
+++ b/examples/udp-codec.rs
@@ -19,15 +19,15 @@ use tokio::prelude::*;
use tokio::net::{UdpSocket, UdpFramed};
use tokio_codec::BytesCodec;
-fn main() {
+fn main() -> Result<(), Box<std::error::Error>> {
let _ = env_logger::init();
- let addr: SocketAddr = "127.0.0.1:0".parse().unwrap();
+ let addr: SocketAddr = "127.0.0.1:0".parse()?;
// Bind both our sockets and then figure out what ports we got.
- let a = UdpSocket::bind(&addr).unwrap();
- let b = UdpSocket::bind(&addr).unwrap();
- let b_addr = b.local_addr().unwrap();
+ let a = UdpSocket::bind(&addr)?;
+ let b = UdpSocket::bind(&addr)?;
+ let b_addr = b.local_addr()?;
// We're parsing each socket with the `BytesCodec` included in `tokio_io`, and then we
// `split` each codec into the sink/stream halves.
@@ -61,4 +61,5 @@ fn main() {
.map(|_| ())
.map_err(|e| println!("error = {:?}", e))
});
+ Ok(())
}