Skip to content

Commit

Permalink
Make Clippy happy
Browse files Browse the repository at this point in the history
  • Loading branch information
dhardy committed Dec 9, 2021
1 parent fe7db8f commit d19a04f
Show file tree
Hide file tree
Showing 14 changed files with 21 additions and 24 deletions.
4 changes: 2 additions & 2 deletions crates/kas-core/src/core/widget.rs
Original file line number Diff line number Diff line change
Expand Up @@ -365,7 +365,7 @@ pub trait Layout: WidgetChildren {
///
/// If used, this allows automatic implementation of `size_rules` and
/// `set_rect` methods. The default case is the empty layout.
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
Default::default() // TODO: remove default impl
}

Expand Down Expand Up @@ -487,7 +487,7 @@ pub trait Layout: WidgetChildren {
return None;
}
let coord = coord + self.translation();
self.layout().find_id(coord).or(Some(self.id()))
self.layout().find_id(coord).or_else(|| Some(self.id()))
}

/// Draw a widget and its children
Expand Down
8 changes: 1 addition & 7 deletions crates/kas-core/src/layout/visitor.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,15 +24,9 @@ use std::iter::ExactSizeIterator;
/// used. We therefore use a simple linked list.
#[cfg_attr(not(feature = "internal_doc"), doc(hidden))]
#[cfg_attr(doc_cfg, doc(cfg(internal_doc)))]
#[derive(Debug)]
#[derive(Debug, Default)]
pub struct StorageChain(Option<(Box<StorageChain>, Box<dyn Storage>)>);

impl Default for StorageChain {
fn default() -> Self {
StorageChain(None)
}
}

impl StorageChain {
/// Access layout storage
///
Expand Down
7 changes: 5 additions & 2 deletions crates/kas-macros/src/args.rs
Original file line number Diff line number Diff line change
Expand Up @@ -396,9 +396,12 @@ pub enum Handler {
Discard,
}
impl Handler {
pub fn is_none(&self) -> bool {
fn is_none(&self) -> bool {
*self == Handler::None
}
fn is_some(&self) -> bool {
*self != Handler::None
}
pub fn any_ref(&self) -> Option<&Ident> {
match self {
Handler::None | Handler::Discard => None,
Expand Down Expand Up @@ -469,7 +472,7 @@ impl Parse for WidgetAttrArgs {

impl ToTokens for WidgetAttrArgs {
fn to_tokens(&self, tokens: &mut TokenStream) {
if !self.update.is_none() || !self.handler.is_none() {
if self.update.is_some() || self.handler.is_some() {
let mut args = TokenStream::new();
if let Some(ref ident) = self.update {
args.append_all(quote! { update = #ident });
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/adapter/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let arr = [
layout::Layout::single(&mut self.inner),
layout::Layout::text(&mut self.label_store, &mut self.label, TextClass::Label),
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/adapter/reserve.rs
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
layout::Layout::single(&mut self.inner)
}

Expand Down
4 changes: 2 additions & 2 deletions crates/kas-widgets/src/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let inner = layout::Layout::single(&mut self.inner);
layout::Layout::button(&mut self.layout_frame, inner, self.color)
}
Expand Down Expand Up @@ -196,7 +196,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let inner = layout::Layout::text(&mut self.layout_text, &mut self.label, TextClass::Button);
layout::Layout::button(&mut self.layout_frame, inner, self.color)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/combobox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ widget! {
}

impl kas::Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let inner = layout::Layout::text(&mut self.layout_text, &mut self.label, TextClass::Button);
layout::Layout::button(&mut self.layout_frame, inner, None)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/editbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let inner = layout::Layout::single(&mut self.inner);
layout::Layout::frame(&mut self.layout_frame, inner)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/frame.rs
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
make_layout!(self.core; frame(self.inner))
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/grid.rs
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
layout::Layout::grid(
self.widgets.iter_mut().map(move |(info, w)| (*info, layout::Layout::single(w))),
self.dim,
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/list.rs
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
make_layout!(self.core; slice(self.direction): self.widgets)
}
}
Expand Down
4 changes: 2 additions & 2 deletions crates/kas-widgets/src/menu/menu_entry.rs
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let inner = layout::Layout::text(&mut self.layout_label, &mut self.label, TextClass::MenuLabel);
layout::Layout::frame(&mut self.layout_frame, inner)
}
Expand Down Expand Up @@ -126,7 +126,7 @@ widget! {
}

impl Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
make_layout!(self.core; row: [self.checkbox, self.label])
}

Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/menu/submenu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,7 +135,7 @@ widget! {
}

impl kas::Layout for Self {
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
let label = layout::Layout::text(&mut self.label_store, &mut self.label, TextClass::MenuLabel);
layout::Layout::frame(&mut self.frame_store, label)
}
Expand Down
2 changes: 1 addition & 1 deletion crates/kas-widgets/src/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@ widget! {

impl Layout for Self {
#[inline]
fn layout<'a>(&'a mut self) -> layout::Layout<'a> {
fn layout(&mut self) -> layout::Layout<'_> {
layout::Layout::single(&mut self.w)
}

Expand Down

0 comments on commit d19a04f

Please sign in to comment.