diff --git a/src/hooks.rs b/src/hooks.rs index a3edf23..fd5b0f5 100644 --- a/src/hooks.rs +++ b/src/hooks.rs @@ -9,9 +9,9 @@ pub struct HookData { pub pub_date: String, } -pub fn run_hook(hook: String, hookdata: Vec) -> Result<(), std::io::Error> { +pub fn run_hook(hook: &str, hookdata: Vec) -> Result<(), std::io::Error> { for data in hookdata { - Command::new(hook.clone()) + Command::new(hook) .env("TITLE", data.title) .env("TITLE_FMT", data.title_fmt) .env("AUTHOR", data.author) diff --git a/src/junction.rs b/src/junction.rs index 12b774c..dd11418 100644 --- a/src/junction.rs +++ b/src/junction.rs @@ -50,7 +50,7 @@ pub fn bundle_rss(state: &mut State, config: &Config) -> (Vec, Channel state.guids.insert(guid.value.clone()); let data = HookData { - title: item.title.as_ref().unwrap_or(&config.default_title).to_owned(), + title: item.title.as_ref().unwrap_or(&config.default_title).clone(), title_fmt: item_title.clone(), author: item.author.clone().unwrap(), link: item.link.clone().unwrap_or_default(), diff --git a/src/main.rs b/src/main.rs index de24607..70dd7f6 100644 --- a/src/main.rs +++ b/src/main.rs @@ -40,7 +40,7 @@ fn main() -> ExitCode { let guids = load_guids().unwrap_or_default(); let state = State { - rss: "".into(), + rss: String::new(), guids, feeds: HashMap::new(), status: None, @@ -66,7 +66,7 @@ fn main() -> ExitCode { } else { None }; if let Some(hook) = &config.hook { - run_hook(hook.to_owned(), hookdata).unwrap(); + run_hook(hook, hookdata).unwrap(); } guard.status = status; @@ -92,7 +92,7 @@ fn load_config() -> Result> { fn load_guids() -> Result, Box> { let content = fs::read_to_string("guids")?; - Ok(content.split("\n").filter(|x| x.len() > 0).map(str::to_owned).collect()) + Ok(content.split('\n').filter(|x| !x.is_empty()).map(str::to_owned).collect()) } fn save_guids(guids: &HashSet) -> Result<(), Box> { diff --git a/src/server.rs b/src/server.rs index c36aa3b..3249ccf 100644 --- a/src/server.rs +++ b/src/server.rs @@ -32,7 +32,7 @@ pub fn start(address: &str, thread_count: usize, state: Arc>) -> Ve continue } }; - let page = url.path().split("/").last().unwrap_or(""); + let page = url.path().split('/').last().unwrap_or(""); let res = match page { "rss.xml" => { let guard = state.lock().unwrap(); @@ -55,4 +55,4 @@ pub fn start(address: &str, thread_count: usize, state: Arc>) -> Ve } threads -} \ No newline at end of file +}