clippy fixes

This commit is contained in:
Emil Ernerfeldt 2020-11-20 12:28:24 +01:00
parent 9a51041ae2
commit 15b0214dff
4 changed files with 4 additions and 12 deletions

View file

@ -125,7 +125,7 @@ pub fn round_to_precision(value: f64, decimal_places: usize) -> f64 {
// This is a stupid way of doing this, but stupid works. // This is a stupid way of doing this, but stupid works.
format!("{:.*}", decimal_places, value) format!("{:.*}", decimal_places, value)
.parse() .parse()
.unwrap_or_else(|_| value) .unwrap_or(value)
} }
pub fn format_with_minimum_precision(value: f32, precision: usize) -> String { pub fn format_with_minimum_precision(value: f32, precision: usize) -> String {

View file

@ -122,11 +122,7 @@ impl<'a> Widget for DragValue<'a> {
if is_kb_editing { if is_kb_editing {
let button_width = ui.style().spacing.interact_size.x; let button_width = ui.style().spacing.interact_size.x;
let mut value_text = ui let mut value_text = ui.memory().temp_edit_string.take().unwrap_or(value_text);
.memory()
.temp_edit_string
.take()
.unwrap_or_else(|| value_text);
let response = ui.add( let response = ui.add(
TextEdit::singleline(&mut value_text) TextEdit::singleline(&mut value_text)
.id(kb_edit_id) .id(kb_edit_id)

View file

@ -119,7 +119,7 @@ impl Label {
/// Read the text style, or get the default for the current style /// Read the text style, or get the default for the current style
pub fn text_style_or_default(&self, style: &Style) -> TextStyle { pub fn text_style_or_default(&self, style: &Style) -> TextStyle {
self.text_style.unwrap_or_else(|| style.body_text_style) self.text_style.unwrap_or(style.body_text_style)
} }
} }

View file

@ -303,11 +303,7 @@ impl<'a> Slider<'a> {
if is_kb_editing { if is_kb_editing {
let button_width = ui.style().spacing.interact_size.x; let button_width = ui.style().spacing.interact_size.x;
let mut value_text = ui let mut value_text = ui.memory().temp_edit_string.take().unwrap_or(value_text);
.memory()
.temp_edit_string
.take()
.unwrap_or_else(|| value_text);
ui.add( ui.add(
TextEdit::singleline(&mut value_text) TextEdit::singleline(&mut value_text)
.id(kb_edit_id) .id(kb_edit_id)