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/chat.rs | |
parent | 477fa5580aa3796f97e3e0eb1325d4690b3b4e96 (diff) |
tests: handle errors properly in examples (#748)
Diffstat (limited to 'examples/chat.rs')
-rw-r--r-- | examples/chat.rs | 7 |
1 files changed, 4 insertions, 3 deletions
diff --git a/examples/chat.rs b/examples/chat.rs index bdc742c9..182af7c8 100644 --- a/examples/chat.rs +++ b/examples/chat.rs @@ -426,7 +426,7 @@ fn process(socket: TcpStream, state: Arc<Mutex<Shared>>) { tokio::spawn(connection); } -pub fn main() { +pub fn main() -> Result<(), Box<std::error::Error>> { // Create the shared state. This is how all the peers communicate. // // The server task will hold a handle to this. For every new client, the @@ -434,12 +434,12 @@ pub fn main() { // client connection. let state = Arc::new(Mutex::new(Shared::new())); - let addr = "127.0.0.1:6142".parse().unwrap(); + let addr = "127.0.0.1:6142".parse()?; // Bind a TCP listener to the socket address. // // Note that this is the Tokio TcpListener, which is fully async. - let listener = TcpListener::bind(&addr).unwrap(); + let listener = TcpListener::bind(&addr)?; // The server task asynchronously iterates over and processes each // incoming connection. @@ -471,4 +471,5 @@ pub fn main() { // In our example, we have not defined a shutdown strategy, so this will // block until `ctrl-c` is pressed at the terminal. tokio::run(server); + Ok(()) } |