src/lib.rs: sync code in doc-comment with examples/basic.rs

is there some way to include the code directly from examples/basic.rs?
This commit is contained in:
Johannes Schilling 2018-08-29 17:37:57 +02:00
parent abad1f4171
commit 515d574742
2 changed files with 15 additions and 10 deletions

View file

@ -16,9 +16,9 @@ fn main() {
let mut imap_session = match client.login("username", "password") { let mut imap_session = match client.login("username", "password") {
Ok(c) => c, Ok(c) => c,
Err((e, _unauth_client)) => { Err((e, _unauth_client)) => {
println!("failed to login: {}", e); eprintln!("failed to login: {}", e);
return; return;
}, }
}; };
match imap_session.capabilities() { match imap_session.capabilities() {

View file

@ -6,9 +6,8 @@
//! See the `examples/` directory for more examples. //! See the `examples/` directory for more examples.
//! //!
//! ```no_run //! ```no_run
//! # extern crate imap; //! extern crate imap;
//! extern crate native_tls; //! extern crate native_tls;
//! # use imap::client::Client;
//! //!
//! // To connect to the gmail IMAP server with this you will need to allow unsecure apps access. //! // To connect to the gmail IMAP server with this you will need to allow unsecure apps access.
//! // See: https://support.google.com/accounts/answer/6010255?hl=en //! // See: https://support.google.com/accounts/answer/6010255?hl=en
@ -18,11 +17,17 @@
//! let port = 993; //! let port = 993;
//! let socket_addr = (domain, port); //! let socket_addr = (domain, port);
//! let ssl_connector = native_tls::TlsConnector::builder().build().unwrap(); //! let ssl_connector = native_tls::TlsConnector::builder().build().unwrap();
//! let mut imap_socket = Client::secure_connect(socket_addr, domain, &ssl_connector).unwrap(); //! let client = imap::client::secure_connect(socket_addr, domain, &ssl_connector).unwrap();
//! //!
//! imap_socket.login("username", "password").unwrap(); //! let mut imap_session = match client.login("username", "password") {
//! Ok(c) => c,
//! Err((e, _unauth_client)) => {
//! eprintln!("failed to login: {}", e);
//! return;
//! }
//! };
//! //!
//! match imap_socket.capabilities() { //! match imap_session.capabilities() {
//! Ok(capabilities) => { //! Ok(capabilities) => {
//! for capability in capabilities.iter() { //! for capability in capabilities.iter() {
//! println!("{}", capability); //! println!("{}", capability);
@ -31,14 +36,14 @@
//! Err(e) => println!("Error parsing capabilities: {}", e), //! Err(e) => println!("Error parsing capabilities: {}", e),
//! }; //! };
//! //!
//! match imap_socket.select("INBOX") { //! match imap_session.select("INBOX") {
//! Ok(mailbox) => { //! Ok(mailbox) => {
//! println!("{}", mailbox); //! println!("{}", mailbox);
//! } //! }
//! Err(e) => println!("Error selecting INBOX: {}", e), //! Err(e) => println!("Error selecting INBOX: {}", e),
//! }; //! };
//! //!
//! match imap_socket.fetch("2", "body[text]") { //! match imap_session.fetch("2", "body[text]") {
//! Ok(messages) => { //! Ok(messages) => {
//! for message in messages.iter() { //! for message in messages.iter() {
//! print!("{:?}", message); //! print!("{:?}", message);
@ -47,7 +52,7 @@
//! Err(e) => println!("Error Fetching email 2: {}", e), //! Err(e) => println!("Error Fetching email 2: {}", e),
//! }; //! };
//! //!
//! imap_socket.logout().unwrap(); //! imap_session.logout().unwrap();
//! } //! }
//! ``` //! ```