From 1c7aa0ec9c8b3c80f7844a315fc002294b198aa5 Mon Sep 17 00:00:00 2001 From: Manos Pitsidianakis Date: Thu, 4 Apr 2019 14:21:52 +0300 Subject: [PATCH] update to 2018 edition --- Cargo.toml | 1 + benches/maildir.rs | 105 +++++++++++------- benches/parse.rs | 18 +-- melib/Cargo.toml | 1 + melib/src/{async.rs => async_workers.rs} | 0 melib/src/lib.rs | 2 +- melib/src/mailbox.rs | 6 +- melib/src/mailbox/backends.rs | 17 ++- melib/src/mailbox/backends/maildir.rs | 10 +- melib/src/mailbox/backends/maildir/backend.rs | 20 ++-- melib/src/mailbox/collection.rs | 6 +- melib/src/mailbox/email.rs | 6 +- melib/src/mailbox/email/attachment_types.rs | 4 +- melib/src/mailbox/email/attachments.rs | 8 +- melib/src/mailbox/email/compose.rs | 6 +- melib/src/mailbox/thread.rs | 7 +- src/bin.rs | 8 +- ui/src/conf/accounts.rs | 8 +- ui/src/workers.rs | 2 +- 19 files changed, 120 insertions(+), 115 deletions(-) rename melib/src/{async.rs => async_workers.rs} (100%) diff --git a/Cargo.toml b/Cargo.toml index dbec664d6..e5431e532 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -2,6 +2,7 @@ name = "meli" version = "0.1.0" authors = ["Manos Pitsidianakis "] +edition = "2018" [[bin]] name = "meli" diff --git a/benches/maildir.rs b/benches/maildir.rs index c83ecd723..2b9707699 100644 --- a/benches/maildir.rs +++ b/benches/maildir.rs @@ -1,43 +1,62 @@ -#![feature(test)] -extern crate melib; -use melib::conf::Folder; -use melib::mailbox::backends::maildir::*; - -extern crate test; -use self::test::Bencher; - -#[bench] -fn bench_threads_1(b: &mut Bencher) { - b.iter(|| { - let folder = Folder::new(String::from(""), String::from(""), vec![]); - MaildirType::new("").multicore(1, &folder) - }); -} -#[bench] -fn bench_threads_2(b: &mut Bencher) { - b.iter(|| { - let folder = Folder::new(String::from(""), String::from(""), vec![]); - MaildirType::new("").multicore(2, &folder) - }); -} -#[bench] -fn bench_threads_3(b: &mut Bencher) { - b.iter(|| { - let folder = Folder::new(String::from(""), String::from(""), vec![]); - MaildirType::new("").multicore(3, &folder) - }); -} -#[bench] -fn bench_threads_4(b: &mut Bencher) { - b.iter(|| { - let folder = Folder::new(String::from(""), String::from(""), vec![]); - MaildirType::new("").multicore(4, &folder) - }); -} -#[bench] -fn bench_threads_6(b: &mut Bencher) { - b.iter(|| { - let folder = Folder::new(String::from(""), String::from(""), vec![]); - MaildirType::new("").multicore(6, &folder) - }); -} +//#![feature(test)] +//use melib::conf::AccountSettings; +//use melib::mailbox::backends::maildir::*; +// +//extern crate test; +//use self::test::Bencher; +// +//#[bench] +//fn bench_threads_1(b: &mut Bencher) { +// b.iter(|| { +// let folder = Folder::new( +// String::from(""), +// String::from(""), +// vec![], +// ); +// MaildirType::new("").multicore(1, &folder) +// }); +//} +//#[bench] +//fn bench_threads_2(b: &mut Bencher) { +// b.iter(|| { +// let folder = Folder::new( +// String::from(""), +// String::from(""), +// vec![], +// ); +// MaildirType::new("").multicore(2, &folder) +// }); +//} +//#[bench] +//fn bench_threads_3(b: &mut Bencher) { +// b.iter(|| { +// let folder = Folder::new( +// String::from(""), +// String::from(""), +// vec![], +// ); +// MaildirType::new("").multicore(3, &folder) +// }); +//} +//#[bench] +//fn bench_threads_4(b: &mut Bencher) { +// b.iter(|| { +// let folder = Folder::new( +// String::from(""), +// String::from(""), +// vec![], +// ); +// MaildirType::new("").multicore(4, &folder) +// }); +//} +//#[bench] +//fn bench_threads_6(b: &mut Bencher) { +// b.iter(|| { +// let folder = Folder::new( +// String::from(""), +// String::from(""), +// vec![], +// ); +// MaildirType::new("").multicore(6, &folder) +// }); +//} diff --git a/benches/parse.rs b/benches/parse.rs index e389841e1..d5a07214b 100644 --- a/benches/parse.rs +++ b/benches/parse.rs @@ -1,12 +1,12 @@ -#![feature(test)] -extern crate melib; - -use melib::mailbox::backends::maildir::MaildirOp; -use melib::mailbox::backends::BackendOpGenerator; -use melib::mailbox::email::Envelope; - -extern crate test; -use self::test::Bencher; +//#![feature(test)] +//extern crate melib; +// +//use melib::mailbox::backends::maildir::MaildirOp; +//use melib::mailbox::backends::BackendOpGenerator; +//use melib::mailbox::email::Envelope; +// +//extern crate test; +//use self::test::Bencher; /* #[bench] diff --git a/melib/Cargo.toml b/melib/Cargo.toml index ba2d27b9b..1cc790c3b 100644 --- a/melib/Cargo.toml +++ b/melib/Cargo.toml @@ -1,6 +1,7 @@ [package] name = "melib" version = "0.0.1" #:version +edition = "2018" authors = [] workspace = ".." diff --git a/melib/src/async.rs b/melib/src/async_workers.rs similarity index 100% rename from melib/src/async.rs rename to melib/src/async_workers.rs diff --git a/melib/src/lib.rs b/melib/src/lib.rs index 7a983a17f..bf2499170 100644 --- a/melib/src/lib.rs +++ b/melib/src/lib.rs @@ -19,7 +19,7 @@ * along with meli. If not, see . */ pub mod addressbook; -pub mod async; +pub mod async_workers; pub mod conf; pub mod error; pub mod mailbox; diff --git a/melib/src/mailbox.rs b/melib/src/mailbox.rs index 4b30ad532..a80544092 100644 --- a/melib/src/mailbox.rs +++ b/melib/src/mailbox.rs @@ -29,10 +29,10 @@ pub mod email; pub use self::email::*; /* Mail backends. Currently only maildir is supported */ pub mod backends; -use error::Result; -use mailbox::backends::Folder; +use crate::error::Result; +use self::backends::Folder; pub mod thread; -pub use mailbox::thread::{SortField, SortOrder, ThreadNode, Threads}; +pub use self::thread::{SortField, SortOrder, ThreadNode, Threads}; mod collection; pub use self::collection::*; diff --git a/melib/src/mailbox/backends.rs b/melib/src/mailbox/backends.rs index 4ba2d010b..0c86552a1 100644 --- a/melib/src/mailbox/backends.rs +++ b/melib/src/mailbox/backends.rs @@ -22,19 +22,18 @@ pub mod imap; pub mod maildir; pub mod mbox; -use async::*; -use conf::AccountSettings; -use error::Result; +use crate::async_workers::*; +use crate::conf::AccountSettings; +use crate::error::Result; //use mailbox::backends::imap::ImapType; //use mailbox::backends::mbox::MboxType; -use mailbox::backends::maildir::MaildirType; -use mailbox::email::{Envelope, EnvelopeHash, Flag}; +use self::maildir::MaildirType; +use super::email::{Envelope, EnvelopeHash, Flag}; use std::fmt; use std::fmt::Debug; use std::ops::Deref; -extern crate fnv; -use self::fnv::FnvHashMap; +use fnv::FnvHashMap; use std; pub type BackendCreator = Box Box>; @@ -209,7 +208,7 @@ pub trait BackendOp: ::std::fmt::Debug + ::std::marker::Send { fn fetch_headers(&mut self) -> Result<&[u8]>; fn fetch_body(&mut self) -> Result<&[u8]>; fn fetch_flags(&self) -> Flag; - fn set_flag(&mut self, &mut Envelope, Flag) -> Result<()>; + fn set_flag(&mut self, envelope: &mut Envelope, flag: Flag) -> Result<()>; } /// `BackendOpGenerator` is a wrapper for a closure that returns a `BackendOp` object @@ -238,7 +237,7 @@ impl fmt::Debug for BackendOpGenerator { pub trait BackendFolder: Debug { fn hash(&self) -> FolderHash; fn name(&self) -> &str; - fn change_name(&mut self, &str); + fn change_name(&mut self, new_name: &str); fn clone(&self) -> Folder; fn children(&self) -> &Vec; } diff --git a/melib/src/mailbox/backends/maildir.rs b/melib/src/mailbox/backends/maildir.rs index 65762cd2a..94418f219 100644 --- a/melib/src/mailbox/backends/maildir.rs +++ b/melib/src/mailbox/backends/maildir.rs @@ -19,15 +19,13 @@ * along with meli. If not, see . */ -extern crate fnv; - mod backend; pub use self::backend::*; -use error::{MeliError, Result}; -use mailbox::backends::*; -use mailbox::email::parser; -use mailbox::email::{Envelope, Flag}; +use crate::error::{MeliError, Result}; +use crate::mailbox::backends::*; +use crate::mailbox::email::parser; +use crate::mailbox::email::{Envelope, Flag}; use memmap::{Mmap, Protection}; use std::collections::hash_map::DefaultHasher; diff --git a/melib/src/mailbox/backends/maildir/backend.rs b/melib/src/mailbox/backends/maildir/backend.rs index 86636cf93..1ae6c6273 100644 --- a/melib/src/mailbox/backends/maildir/backend.rs +++ b/melib/src/mailbox/backends/maildir/backend.rs @@ -19,22 +19,17 @@ * along with meli. If not, see . */ -extern crate bincode; -extern crate fnv; -extern crate notify; -extern crate xdg; - use super::{MaildirFolder, MaildirOp}; -use async::*; -use conf::AccountSettings; -use error::{MeliError, Result}; -use mailbox::backends::{ +use crate::async_workers::*; +use crate::conf::AccountSettings; +use crate::error::{MeliError, Result}; +use super::{ BackendFolder, BackendOp, Folder, FolderHash, MailBackend, RefreshEvent, RefreshEventConsumer, RefreshEventKind::*, }; -use mailbox::email::{Envelope, EnvelopeHash}; +use crate::mailbox::email::{Envelope, EnvelopeHash}; -use self::notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; +use notify::{watcher, DebouncedEvent, RecursiveMode, Watcher}; use std::time::Duration; use std::sync::mpsc::channel; @@ -42,8 +37,7 @@ use std::sync::mpsc::channel; //use std::sync::mpsc::SyncSender; //use std::time::Duration; use std::thread; -extern crate crossbeam; -use self::fnv::{FnvHashMap, FnvHasher}; +use fnv::{FnvHashMap, FnvHasher}; use std::collections::hash_map::DefaultHasher; use std::ffi::OsStr; use std::fs; diff --git a/melib/src/mailbox/collection.rs b/melib/src/mailbox/collection.rs index 9dffab4ba..a44d895d6 100644 --- a/melib/src/mailbox/collection.rs +++ b/melib/src/mailbox/collection.rs @@ -1,14 +1,10 @@ -extern crate bincode; -extern crate xdg; - use super::*; use std::collections::BTreeMap; use std::fs; use std::io; use std::ops::{Deref, DerefMut}; -extern crate fnv; -use self::fnv::FnvHashMap; +use fnv::FnvHashMap; /// `Mailbox` represents a folder of mail. #[derive(Debug, Clone, Default)] diff --git a/melib/src/mailbox/email.rs b/melib/src/mailbox/email.rs index 6b8b97cd9..78f17ea8c 100644 --- a/melib/src/mailbox/email.rs +++ b/melib/src/mailbox/email.rs @@ -28,12 +28,12 @@ pub use self::compose::*; mod attachment_types; pub mod attachments; -pub use self::attachments::*; +pub use crate::attachments::*; pub mod parser; use parser::BytesExt; -use error::{MeliError, Result}; -use mailbox::backends::BackendOp; +use crate::error::{MeliError, Result}; +use super::backends::BackendOp; use std::borrow::Cow; use std::cmp::Ordering; diff --git a/melib/src/mailbox/email/attachment_types.rs b/melib/src/mailbox/email/attachment_types.rs index da1162c76..ba9b6102b 100644 --- a/melib/src/mailbox/email/attachment_types.rs +++ b/melib/src/mailbox/email/attachment_types.rs @@ -1,5 +1,5 @@ -use mailbox::email::attachments::Attachment; -use mailbox::email::parser::BytesExt; +use crate::mailbox::email::attachments::Attachment; +use crate::mailbox::email::parser::BytesExt; use std::fmt::{Display, Formatter, Result as FmtResult}; use std::str; diff --git a/melib/src/mailbox/email/attachments.rs b/melib/src/mailbox/email/attachments.rs index dadba2297..a39290127 100644 --- a/melib/src/mailbox/email/attachments.rs +++ b/melib/src/mailbox/email/attachments.rs @@ -19,13 +19,13 @@ * along with meli. If not, see . */ use data_encoding::BASE64_MIME; -use mailbox::email::parser; -use mailbox::email::parser::BytesExt; -use mailbox::email::EnvelopeWrapper; +use crate::mailbox::email::parser; +use crate::mailbox::email::parser::BytesExt; +use crate::mailbox::email::EnvelopeWrapper; use std::fmt; use std::str; -pub use mailbox::email::attachment_types::*; +pub use crate::mailbox::email::attachment_types::*; /* * diff --git a/melib/src/mailbox/email/compose.rs b/melib/src/mailbox/email/compose.rs index 6161b0bb2..9841c5c85 100644 --- a/melib/src/mailbox/email/compose.rs +++ b/melib/src/mailbox/email/compose.rs @@ -1,7 +1,7 @@ use super::*; use chrono::{DateTime, Local}; use data_encoding::BASE64_MIME; -use mailbox::backends::BackendOp; +use crate::mailbox::backends::BackendOp; use std::str; mod mime; @@ -10,9 +10,7 @@ mod random; //use self::mime::*; use super::parser; - -extern crate fnv; -use self::fnv::FnvHashMap; +use fnv::FnvHashMap; #[derive(Debug, PartialEq)] pub struct Draft { diff --git a/melib/src/mailbox/thread.rs b/melib/src/mailbox/thread.rs index 78916e936..2a91b53c5 100644 --- a/melib/src/mailbox/thread.rs +++ b/melib/src/mailbox/thread.rs @@ -32,11 +32,10 @@ * user having mutable ownership. */ -use mailbox::email::parser::BytesExt; -use mailbox::email::*; +use crate::mailbox::email::parser::BytesExt; +use crate::mailbox::email::*; -extern crate fnv; -use self::fnv::{FnvHashMap, FnvHashSet}; +use fnv::{FnvHashMap, FnvHashSet}; use std::cell::{Ref, RefCell}; use std::cmp; use std::cmp::Ordering; diff --git a/src/bin.rs b/src/bin.rs index 3e268e20c..c90a13c9d 100644 --- a/src/bin.rs +++ b/src/bin.rs @@ -29,19 +29,19 @@ use std::alloc::System; #[global_allocator] static GLOBAL: System = System; -extern crate melib; -extern crate ui; + +use ui; pub use melib::*; pub use ui::*; #[macro_use] extern crate chan; -extern crate chan_signal; +use chan_signal; use chan_signal::Signal; -extern crate nix; +use nix; fn main() { /* Lock all stdio outs */ diff --git a/ui/src/conf/accounts.rs b/ui/src/conf/accounts.rs index d739649c4..aefa1cf37 100644 --- a/ui/src/conf/accounts.rs +++ b/ui/src/conf/accounts.rs @@ -23,12 +23,12 @@ * Account management from user configuration. */ -use async::*; -use conf::AccountConf; -use mailbox::backends::{ +use melib::async_workers::{Async, AsyncStatus, AsyncBuilder}; +use super::AccountConf; +use melib::mailbox::backends::{ Backends, Folder, MailBackend, NotifyFn, RefreshEvent, RefreshEventConsumer, RefreshEventKind, }; -use mailbox::*; +use melib::mailbox::*; use melib::error::Result; use melib::AddressBook; diff --git a/ui/src/workers.rs b/ui/src/workers.rs index ecc8b8d9e..3214ff77e 100644 --- a/ui/src/workers.rs +++ b/ui/src/workers.rs @@ -1,5 +1,5 @@ use chan; -use melib::async::Work; +use melib::async_workers::Work; use std; use std::mem; use std::thread;