Skip to content

Commit

Permalink
Apply some Clippy suggestions
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Apr 24, 2024
1 parent 04d3fd8 commit d0379ee
Show file tree
Hide file tree
Showing 5 changed files with 29 additions and 38 deletions.
4 changes: 1 addition & 3 deletions crates/kas-core/src/app/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -338,9 +338,7 @@ impl<A: AppData, G: AppGraphicsBuilder, T: Theme<G::Shared>> Window<A, G, T> {
}

pub(super) fn update_timer(&mut self, state: &mut AppState<A, G, T>) -> Option<Instant> {
let Some(ref window) = self.window else {
return None;
};
let window = self.window.as_ref()?;

let widget = self.widget.as_node(&state.data);
let mut messages = MessageStack::new();
Expand Down
1 change: 0 additions & 1 deletion crates/kas-core/src/event/cx/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@ use std::future::Future;
use std::ops::{Deref, DerefMut};
use std::pin::Pin;
use std::time::Instant;
use std::u16;

use super::config::WindowConfig;
use super::*;
Expand Down
50 changes: 22 additions & 28 deletions crates/kas-macros/src/make_layout.rs
Original file line number Diff line number Diff line change
Expand Up @@ -70,30 +70,26 @@ impl Tree {
&self,
children: I,
) -> std::result::Result<Toks, (Span, &'static str)> {
match &self.0 {
layout => {
let mut v = Vec::new();
layout.nav_next(children, &mut v).map(|()| {
quote! {
fn nav_next(&self, reverse: bool, from: Option<usize>) -> Option<usize> {
let mut iter = [#(#v),*].into_iter();
if !reverse {
if let Some(wi) = from {
let _ = iter.find(|x| *x == wi);
}
iter.next()
} else {
let mut iter = iter.rev();
if let Some(wi) = from {
let _ = iter.find(|x| *x == wi);
}
iter.next()
}
let mut v = Vec::new();
self.0.nav_next(children, &mut v).map(|()| {
quote! {
fn nav_next(&self, reverse: bool, from: Option<usize>) -> Option<usize> {
let mut iter = [#(#v),*].into_iter();
if !reverse {
if let Some(wi) = from {
let _ = iter.find(|x| *x == wi);
}
iter.next()
} else {
let mut iter = iter.rev();
if let Some(wi) = from {
let _ = iter.find(|x| *x == wi);
}
iter.next()
}
})
}
}
}
})
}

/// If field `ident` is included in the layout, return Span of usage
Expand Down Expand Up @@ -477,7 +473,7 @@ impl Layout {
);

// Clear remainder of input stream to avoid a redundant error
let _ = input.step(|cursor| {
input.step(|cursor| {
let mut rest = *cursor;
while let Some((_, next)) = rest.token_tree() {
rest = next;
Expand Down Expand Up @@ -1090,12 +1086,10 @@ impl Layout {
}
Layout::Widget(ident, _) => {
for (i, child) in children.enumerate() {
if let ChildIdent::CoreField(ref child_ident) = child.ident {
if let Member::Named(ref ci) = child_ident {
if *ident == *ci {
output.push(i);
return Ok(());
}
if let ChildIdent::CoreField(Member::Named(ref ci)) = child.ident {
if *ident == *ci {
output.push(i);
return Ok(());
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-macros/src/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -180,7 +180,7 @@ pub struct Child {
impl Child {
pub fn new_core(ident: Member) -> Self {
Child {
ident: ChildIdent::CoreField(ident.into()),
ident: ChildIdent::CoreField(ident),
attr_span: None,
data_binding: None,
}
Expand Down
10 changes: 5 additions & 5 deletions crates/kas-resvg/src/canvas.rs
Original file line number Diff line number Diff line change
Expand Up @@ -113,13 +113,13 @@ impl_scope! {
/// Use [`Self::with_size`] or [`Self::with_scaling`] to set the initial size.
#[inline]
pub fn new(program: P) -> Self {
let mut scaling = PixmapScaling::default();
scaling.size = LogicalSize(128.0, 128.0);
scaling.stretch = Stretch::High;

Canvas {
core: Default::default(),
scaling,
scaling: PixmapScaling {
size: LogicalSize(128.0, 128.0),
stretch: Stretch::High,
..Default::default()
},
inner: State::Initial(program),
image: None,
}
Expand Down

0 comments on commit d0379ee

Please sign in to comment.