diff --git a/src/data.rs b/src/data.rs index 191b6c4..bd7addd 100644 --- a/src/data.rs +++ b/src/data.rs @@ -8,7 +8,7 @@ use crate::{ forecast::{round_to_last_weather_time, Forecast, ForecastSet, Rate}, }; -const DATA: &'static str = include_str!("../data.json"); +const DATA: &str = include_str!("../data.json"); #[derive(Serialize, Deserialize, Debug)] pub struct Data { @@ -104,6 +104,7 @@ pub struct Window { pub duration: Duration, } +#[allow(clippy::needless_lifetimes)] impl<'a> CombinedFish<'a> { /// Fills in the rest of the struct. pub fn find_uptime(&mut self, data: &Data) { @@ -147,17 +148,15 @@ impl<'a> CombinedFish<'a> { let spans_midnight = start_hour > end_hour; let cur_hour = et.hour() as f32 + et.minute() as f32 / 60.; if spans_midnight { - return cur_hour > start_hour || cur_hour < end_hour; + cur_hour > start_hour || cur_hour < end_hour } else { - return start_hour < cur_hour && cur_hour < end_hour; + start_hour < cur_hour && cur_hour < end_hour } } /// Gets the associated forecast struct. pub fn get_forecast<'b>(&self, data: &'b Data) -> Option<&'b Forecast> { - if self.entry.location.is_none() { - return None; - } + self.entry.location?; // Find the associated fishing spot. let spot = data .db_data @@ -223,14 +222,14 @@ impl<'a> CombinedFish<'a> { // Skip ahead by 8-hour intervals, to quickly find the next favorable weather. let mut date = round_to_last_weather_time(clock::get_current_eorzea_date()); // Start with the next weather cycle. - date = date + Duration::hours(8); + date += Duration::hours(8); let mut results = Vec::new(); for _i in 1..cycles { while !self.is_in_correct_weather_at(forecast, date) { - date = date + Duration::hours(8); + date += Duration::hours(8); } - results.push(date.clone()); - date = date + Duration::hours(8); + results.push(date); + date += Duration::hours(8); } results } @@ -238,11 +237,12 @@ impl<'a> CombinedFish<'a> { // Given a forecast and a start date of a window, find how long that weather stays. pub fn get_weather_duration(&self, forecast: &Forecast, date: &DateTime) -> Duration { let mut length = 0; + #[allow(clippy::clone_on_copy)] let mut date = date.clone(); let mut cur_pattern = forecast.weather_at(date).weather_id; while self.entry.weather_set.iter().any(|w| w == &cur_pattern) { length += 8; - date = date + Duration::hours(8); + date += Duration::hours(8); cur_pattern = forecast.weather_at(date).weather_id; } Duration::hours(length) @@ -273,7 +273,7 @@ impl<'a> CombinedFish<'a> { // window the next iteration. let next_end = next_start + duration; if next_start.day() == next_end.day() { - idx_date = idx_date + Duration::days(1); + idx_date += Duration::days(1); } else { idx_date = next_end; } @@ -308,7 +308,7 @@ impl<'a> CombinedFish<'a> { duration, }); - idx_date = idx_date + duration; + idx_date += duration; } else if has_time_constraint && has_weather { // Calculate start and end times for both the weather uptime and the time-based uptime. let w_duration = if self.entry.previous_weather_set.is_empty() { @@ -375,9 +375,9 @@ impl<'a> CombinedFish<'a> { }) } - idx_date = idx_date + w_duration; + idx_date += w_duration; } else { - idx_date = idx_date + Duration::hours(8); + idx_date += Duration::hours(8); } } @@ -389,6 +389,7 @@ impl<'a> CombinedFish<'a> { } } +#[allow(clippy::new_without_default)] impl Data { pub fn new() -> Self { let json = &mut serde_json::Deserializer::from_str(DATA); @@ -399,7 +400,7 @@ impl Data { .iter() .map(|(id, wr)| { ( - id.clone(), + *id, Forecast { zone_id: wr.zone_id, rates: wr @@ -433,7 +434,7 @@ impl Data { rarity: 1., // dito }; cfish.find_uptime(self); - (k.clone(), cfish) + (*k, cfish) }) }) .collect() diff --git a/src/templates.rs b/src/templates.rs index f3073b7..c71a963 100644 --- a/src/templates.rs +++ b/src/templates.rs @@ -1,4 +1,4 @@ -use std::{cmp::Ordering, sync::Arc}; +use std::sync::Arc; use axum::extract::State; use maud::{html, Markup, DOCTYPE};