From 22402f0f46a353deb345391df02ec2c99efd6c2a Mon Sep 17 00:00:00 2001 From: VC Date: Sun, 24 Apr 2022 11:01:46 +0200 Subject: [PATCH] refactor: optimize import and last_tweet_id var --- src/lib.rs | 5 +---- src/mastodon.rs | 1 - src/twitter.rs | 4 ---- src/util.rs | 5 ----- 4 files changed, 1 insertion(+), 14 deletions(-) diff --git a/src/lib.rs b/src/lib.rs index 779cb7e..bb50934 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -33,10 +33,7 @@ pub async fn run(config: Config) { // open the SQLite connection let conn = Connection::open(&config.scootaloo.db_path).unwrap(); // retrieve the last tweet ID for the username - let last_tweet_id = match read_state(&conn, None).unwrap() { - Some(i) => Some(i.tweet_id), - None => None, - }; + let last_tweet_id = read_state(&conn, None).unwrap().map(|s| s.tweet_id); // get OAuth2 token let token = get_oauth2_token(&config.twitter); diff --git a/src/mastodon.rs b/src/mastodon.rs index d2a51a1..55f319e 100644 --- a/src/mastodon.rs +++ b/src/mastodon.rs @@ -17,7 +17,6 @@ use elefren::{ scopes::Scopes, }; - /// Decodes the Twitter mention to something that will make sense once Twitter has joined the /// Fediverse fn twitter_mentions(ums: &Vec) -> HashMap { diff --git a/src/twitter.rs b/src/twitter.rs index 5821bb0..5475f68 100644 --- a/src/twitter.rs +++ b/src/twitter.rs @@ -1,12 +1,8 @@ -// auto-imports use crate::ScootalooError; use crate::config::TwitterConfig; use crate::util::cache_media; -// std use std::error::Error; - -// egg-mode use egg_mode::{ Token, KeyPair, diff --git a/src/util.rs b/src/util.rs index 7e220fe..f665882 100644 --- a/src/util.rs +++ b/src/util.rs @@ -1,11 +1,6 @@ -// std use std::error::Error; use crate::ScootalooError; - -// reqwest use reqwest::Url; - -// tokio use tokio::{ io::copy, fs::{File, create_dir_all},