diff options
| author | Jokler <jokler.contact@gmail.com> | 2018-02-24 20:13:32 +0100 |
|---|---|---|
| committer | Jokler <jokler.contact@gmail.com> | 2018-02-24 20:13:32 +0100 |
| commit | ce2db228aac1c0114bcac30bb6c01212faca025a (patch) | |
| tree | 73dc3b12bbeccfcfde6151bc629a7d0e02397c88 /src/main.rs | |
| parent | f24da1f5090d71a4963e05c5a76dad2eccac15bd (diff) | |
| download | frippy-ce2db228aac1c0114bcac30bb6c01212faca025a.tar.gz frippy-ce2db228aac1c0114bcac30bb6c01212faca025a.zip | |
Run rustfmt and clippy
Diffstat (limited to 'src/main.rs')
| -rw-r--r-- | src/main.rs | 34 |
1 files changed, 15 insertions, 19 deletions
diff --git a/src/main.rs b/src/main.rs index 6605693..511fe09 100644 --- a/src/main.rs +++ b/src/main.rs @@ -7,11 +7,11 @@ extern crate irc; extern crate time; #[cfg(feature = "mysql")] +extern crate diesel; +#[cfg(feature = "mysql")] #[macro_use] extern crate diesel_migrations; #[cfg(feature = "mysql")] -extern crate diesel; -#[cfg(feature = "mysql")] extern crate r2d2; #[cfg(feature = "mysql")] extern crate r2d2_diesel; @@ -103,10 +103,7 @@ fn main() { let mut mysql_url = None; if let Some(ref options) = config.options { if let Some(disabled) = options.get("disabled_plugins") { - disabled_plugins = Some(disabled - .split(",") - .map(|p| p.trim()) - .collect::<Vec<_>>()); + disabled_plugins = Some(disabled.split(',').map(|p| p.trim()).collect::<Vec<_>>()); } mysql_url = options.get("mysql_url"); @@ -129,18 +126,18 @@ fn main() { let manager = ConnectionManager::<MysqlConnection>::new(url.clone()); match r2d2::Pool::builder().build(manager) { - Ok(pool) => { - match embedded_migrations::run(&*pool.get().expect("Failed to get connection")) { - Ok(_) => { - bot.add_plugin(plugins::Factoids::new(pool)); - info!("Connected to MySQL server") - } - Err(e) => { - bot.add_plugin(plugins::Factoids::new(HashMap::new())); - error!("Failed to run migrations: {}", e); - } + Ok(pool) => match embedded_migrations::run(&*pool.get() + .expect("Failed to get connection")) + { + Ok(_) => { + bot.add_plugin(plugins::Factoids::new(pool)); + info!("Connected to MySQL server") + } + Err(e) => { + bot.add_plugin(plugins::Factoids::new(HashMap::new())); + error!("Failed to run migrations: {}", e); } - } + }, Err(e) => error!("Failed to connect to database: {}", e), } } else { @@ -149,13 +146,12 @@ fn main() { } #[cfg(not(feature = "mysql"))] { - if let Some(_) = mysql_url { + if mysql_url.is_some() { error!("frippy was not built with the mysql feature") } bot.add_plugin(plugins::Factoids::new(HashMap::new())); } - if let Some(disabled_plugins) = disabled_plugins { for name in disabled_plugins { if bot.remove_plugin(name).is_none() { |
