From 7485fb866b6f212e9e1f7cc377bd7bc46aa969cc Mon Sep 17 00:00:00 2001 From: Jan Pochyla Date: Thu, 18 Nov 2021 21:03:45 +0100 Subject: [PATCH] Fix clippy warnings --- psst-gui/src/controller/input.rs | 4 +++- psst-gui/src/data/ctx.rs | 4 ---- psst-gui/src/data/utils.rs | 12 ++++-------- psst-gui/src/webapi/client.rs | 2 +- psst-gui/src/widget/icons.rs | 2 -- 5 files changed, 8 insertions(+), 16 deletions(-) diff --git a/psst-gui/src/controller/input.rs b/psst-gui/src/controller/input.rs index 0100a118..ebab216a 100644 --- a/psst-gui/src/controller/input.rs +++ b/psst-gui/src/controller/input.rs @@ -6,8 +6,10 @@ use druid::{ use crate::cmd; +type SubmitHandler = Box; + pub struct InputController { - on_submit: Option>, + on_submit: Option, } impl InputController { diff --git a/psst-gui/src/data/ctx.rs b/psst-gui/src/data/ctx.rs index 731f514e..0aa2abbc 100644 --- a/psst-gui/src/data/ctx.rs +++ b/psst-gui/src/data/ctx.rs @@ -27,10 +27,6 @@ where CtxMake { cl, tl } } - pub fn ctx() -> impl Lens { - Field::new(|c: &Self| &c.ctx, |c: &mut Self| &mut c.ctx) - } - pub fn data() -> impl Lens { Field::new(|c: &Self| &c.data, |c: &mut Self| &mut c.data) } diff --git a/psst-gui/src/data/utils.rs b/psst-gui/src/data/utils.rs index 8335b199..57286079 100644 --- a/psst-gui/src/data/utils.rs +++ b/psst-gui/src/data/utils.rs @@ -17,24 +17,20 @@ pub struct Cached { } impl Cached { - pub fn fresh(data: T) -> Self { + pub fn new(data: T, at: SystemTime) -> Self { Self { data, - cached_at: None, + cached_at: Some(at), } } - pub fn cached(data: T, at: SystemTime) -> Self { + pub fn fresh(data: T) -> Self { Self { data, - cached_at: Some(at), + cached_at: None, } } - pub fn is_cached(&self) -> bool { - self.cached_at.is_some() - } - pub fn map(self, f: impl Fn(T) -> U) -> Cached { Cached { data: f(self.data), diff --git a/psst-gui/src/webapi/client.rs b/psst-gui/src/webapi/client.rs index 5580a232..e9e59ce1 100644 --- a/psst-gui/src/webapi/client.rs +++ b/psst-gui/src/webapi/client.rs @@ -124,7 +124,7 @@ impl WebApi { if let Some(file) = self.cache.get(bucket, key) { let cached_at = file.metadata()?.modified()?; let value = serde_json::from_reader(file)?; - Ok(Cached::cached(value, cached_at)) + Ok(Cached::new(value, cached_at)) } else { let response = Self::with_retry(|| Ok(request.clone().call()?))?; let body = { diff --git a/psst-gui/src/widget/icons.rs b/psst-gui/src/widget/icons.rs index 394e5ecd..dda96388 100644 --- a/psst-gui/src/widget/icons.rs +++ b/psst-gui/src/widget/icons.rs @@ -121,7 +121,6 @@ pub static PLAYLIST: SvgIcon = SvgIcon { #[derive(Copy, Clone)] pub enum PaintOp { Fill, - Stroke { width: f64 }, } #[derive(Clone)] @@ -190,7 +189,6 @@ impl Widget for Icon { ctx.transform(self.scale); match self.op { PaintOp::Fill => ctx.fill(&self.bez_path, &color), - PaintOp::Stroke { width } => ctx.stroke(&self.bez_path, &color, width), } }); }