From e142f5d1b58184ebae953e4e99095f3237b7db13 Mon Sep 17 00:00:00 2001 From: Joonas Javanainen Date: Sat, 13 Jul 2019 15:37:09 +0300 Subject: [PATCH] Fix several clippy nits --- src/input/keyboard.rs | 4 ++-- src/render/draw_data.rs | 4 +++- src/widget/image.rs | 2 +- src/widget/menu.rs | 27 +++++++++++++++------------ src/widget/progress_bar.rs | 2 +- src/widget/selectable.rs | 2 +- 6 files changed, 23 insertions(+), 18 deletions(-) diff --git a/src/input/keyboard.rs b/src/input/keyboard.rs index b3105a4..e452e65 100644 --- a/src/input/keyboard.rs +++ b/src/input/keyboard.rs @@ -78,8 +78,8 @@ pub enum FocusedWidget { } impl FocusedWidget { - fn as_offset(&self) -> i32 { - match *self { + fn as_offset(self) -> i32 { + match self { FocusedWidget::Previous => -1, FocusedWidget::Next => 0, FocusedWidget::Offset(offset) => offset as i32, diff --git a/src/render/draw_data.rs b/src/render/draw_data.rs index 50d60f5..2823a71 100644 --- a/src/render/draw_data.rs +++ b/src/render/draw_data.rs @@ -169,7 +169,9 @@ impl<'a> Iterator for DrawCmdIterator<'a> { idx_offset: cmd.IdxOffset as usize, }; match cmd.UserCallback { - Some(raw_callback) if raw_callback as isize == -1 => DrawCmd::ResetRenderState, + Some(raw_callback) if raw_callback as usize == -1isize as usize => { + DrawCmd::ResetRenderState + } Some(raw_callback) => DrawCmd::RawCallback { callback: raw_callback, raw_cmd: cmd, diff --git a/src/widget/image.rs b/src/widget/image.rs index 6f949ed..e805520 100644 --- a/src/widget/image.rs +++ b/src/widget/image.rs @@ -115,7 +115,7 @@ impl ImageButton { /// - `= 0`: no framing /// - `> 0`: set framing size pub fn frame_padding(mut self, frame_padding: i32) -> Self { - self.frame_padding = frame_padding.into(); + self.frame_padding = frame_padding; self } /// Sets the background color (default: no background color) diff --git a/src/widget/menu.rs b/src/widget/menu.rs index 5ce4948..f6029ea 100644 --- a/src/widget/menu.rs +++ b/src/widget/menu.rs @@ -10,28 +10,31 @@ impl<'ui> Ui<'ui> { /// Creates and starts appending to a full-screen menu bar. /// /// Returns `None` if the menu bar is not visible and no content should be rendered. - pub fn main_menu_bar<'a>(&'a self) -> Option> { - match unsafe { sys::igBeginMainMenuBar() } { - true => Some(MainMenuBarToken { _ui: PhantomData }), - false => None, + pub fn main_menu_bar(&self) -> Option { + if unsafe { sys::igBeginMainMenuBar() } { + Some(MainMenuBarToken { _ui: PhantomData }) + } else { + None } } /// Creates and starts appending to the menu bar of the current window. /// /// Returns `None` if the menu bar is not visible and no content should be rendered. - pub fn menu_bar<'a>(&'a self) -> Option> { - match unsafe { sys::igBeginMenuBar() } { - true => Some(MenuBarToken { _ui: PhantomData }), - false => None, + pub fn menu_bar(&self) -> Option { + if unsafe { sys::igBeginMenuBar() } { + Some(MenuBarToken { _ui: PhantomData }) + } else { + None } } /// Creates and starts appending to a sub-menu entry. /// /// Returns `None` if the menu is not visible and no content should be rendered. - pub fn menu<'a>(&'a self, label: &ImStr, enabled: bool) -> Option> { - match unsafe { sys::igBeginMenu(label.as_ptr(), enabled) } { - true => Some(MenuToken { _ui: PhantomData }), - false => None, + pub fn menu(&self, label: &ImStr, enabled: bool) -> Option { + if unsafe { sys::igBeginMenu(label.as_ptr(), enabled) } { + Some(MenuToken { _ui: PhantomData }) + } else { + None } } } diff --git a/src/widget/progress_bar.rs b/src/widget/progress_bar.rs index 0383f85..3dc002b 100644 --- a/src/widget/progress_bar.rs +++ b/src/widget/progress_bar.rs @@ -51,7 +51,7 @@ impl<'a> ProgressBar<'a> { /// bar choose a size, and positive values will use the given size. #[inline] pub fn size(mut self, size: [f32; 2]) -> Self { - self.size = size.into(); + self.size = size; self } /// Builds the progress bar diff --git a/src/widget/selectable.rs b/src/widget/selectable.rs index ff7cfc7..5aa80d3 100644 --- a/src/widget/selectable.rs +++ b/src/widget/selectable.rs @@ -98,7 +98,7 @@ impl<'a> Selectable<'a> { /// - `= 0.0`: use label height #[inline] pub fn size(mut self, size: [f32; 2]) -> Self { - self.size = size.into(); + self.size = size; self } /// Builds the selectable.