From 964d7c99ef7d676533377874a35bd9e15f7efff6 Mon Sep 17 00:00:00 2001 From: Matt McCoy Date: Fri, 24 Jun 2016 20:40:56 -0400 Subject: [PATCH] Making the basic example more readable --- examples/basic.rs | 13 +++---------- 1 file changed, 3 insertions(+), 10 deletions(-) diff --git a/examples/basic.rs b/examples/basic.rs index 0f166cd..e0e9b75 100644 --- a/examples/basic.rs +++ b/examples/basic.rs @@ -6,14 +6,9 @@ use imap::client::Client; use imap::mailbox::Mailbox; fn main() { - let mut imap_socket = match Client::secure_connect(("imap.gmail.com", 993), SslContext::new(SslMethod::Sslv23).unwrap()) { - Ok(s) => s, - Err(e) => panic!("{}", e) - }; + let mut imap_socket = Client::secure_connect(("imap.gmail.com", 993), SslContext::new(SslMethod::Sslv23).unwrap()).unwrap(); - if let Err(e) = imap_socket.login("username", "password") { - println!("Error: {}", e) - }; + imap_socket.login("username", "password").unwrap(); match imap_socket.capability() { Ok(capabilities) => { @@ -40,7 +35,5 @@ fn main() { Err(_) => println!("Error Fetching email 2") }; - if let Err(e) = imap_socket.logout() { - println!("Error: {}", e) - }; + imap_socket.logout().unwrap(); }