Skip to content

Commit

Permalink
Fix clippy warnings
Browse files Browse the repository at this point in the history
  • Loading branch information
jpochyla committed Nov 18, 2021
1 parent b6aa8cb commit 7485fb8
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 16 deletions.
4 changes: 3 additions & 1 deletion psst-gui/src/controller/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,10 @@ use druid::{

use crate::cmd;

type SubmitHandler = Box<dyn Fn(&mut EventCtx, &mut String, &Env)>;

pub struct InputController {
on_submit: Option<Box<dyn Fn(&mut EventCtx, &mut String, &Env)>>,
on_submit: Option<SubmitHandler>,
}

impl InputController {
Expand Down
4 changes: 0 additions & 4 deletions psst-gui/src/data/ctx.rs
Original file line number Diff line number Diff line change
Expand Up @@ -27,10 +27,6 @@ where
CtxMake { cl, tl }
}

pub fn ctx() -> impl Lens<Self, C> {
Field::new(|c: &Self| &c.ctx, |c: &mut Self| &mut c.ctx)
}

pub fn data() -> impl Lens<Self, T> {
Field::new(|c: &Self| &c.data, |c: &mut Self| &mut c.data)
}
Expand Down
12 changes: 4 additions & 8 deletions psst-gui/src/data/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,24 +17,20 @@ pub struct Cached<T: Data> {
}

impl<T: Data> Cached<T> {
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<U: Data>(self, f: impl Fn(T) -> U) -> Cached<U> {
Cached {
data: f(self.data),
Expand Down
2 changes: 1 addition & 1 deletion psst-gui/src/webapi/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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 = {
Expand Down
2 changes: 0 additions & 2 deletions psst-gui/src/widget/icons.rs
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,6 @@ pub static PLAYLIST: SvgIcon = SvgIcon {
#[derive(Copy, Clone)]
pub enum PaintOp {
Fill,
Stroke { width: f64 },
}

#[derive(Clone)]
Expand Down Expand Up @@ -190,7 +189,6 @@ impl<T> Widget<T> 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),
}
});
}
Expand Down

0 comments on commit 7485fb8

Please sign in to comment.