Enable and fix some more clippy lints (#7426)
One can never have too many lints
This commit is contained in:
parent
e8e99a0bb6
commit
3024c39eaf
16
Cargo.toml
16
Cargo.toml
|
|
@ -159,8 +159,8 @@ disallowed_types = "warn" # See clippy.toml
|
|||
doc_link_with_quotes = "warn"
|
||||
doc_markdown = "warn"
|
||||
empty_enum = "warn"
|
||||
empty_line_after_outer_attr = "warn"
|
||||
empty_enum_variants_with_brackets = "warn"
|
||||
empty_line_after_outer_attr = "warn"
|
||||
enum_glob_use = "warn"
|
||||
equatable_if_let = "warn"
|
||||
exit = "warn"
|
||||
|
|
@ -180,6 +180,7 @@ if_let_mutex = "warn"
|
|||
implicit_clone = "warn"
|
||||
implied_bounds_in_impls = "warn"
|
||||
imprecise_flops = "warn"
|
||||
inconsistent_struct_constructor = "warn"
|
||||
index_refutable_slice = "warn"
|
||||
inefficient_to_string = "warn"
|
||||
infinite_loop = "warn"
|
||||
|
|
@ -295,8 +296,21 @@ verbose_file_reads = "warn"
|
|||
wildcard_dependencies = "warn"
|
||||
zero_sized_map_values = "warn"
|
||||
|
||||
# Enable these when we update MSRV:
|
||||
# doc_comment_double_space_linebreaks = "warn"
|
||||
# elidable_lifetime_names = "warn"
|
||||
# ignore_without_reason = "warn"
|
||||
# manual_midpoint = "warn"
|
||||
# non_std_lazy_statics = "warn"
|
||||
# precedence_bits = "warn"
|
||||
# return_and_then = "warn"
|
||||
# single_option_map = "warn"
|
||||
# unnecessary_debug_formatting = "warn"
|
||||
# unnecessary_semicolon = "warn"
|
||||
|
||||
|
||||
# TODO(emilk): maybe enable more of these lints?
|
||||
comparison_chain = "allow"
|
||||
should_panic_without_expect = "allow"
|
||||
too_many_lines = "allow"
|
||||
unwrap_used = "allow" # TODO(emilk): We really wanna warn on this one
|
||||
|
|
|
|||
|
|
@ -234,7 +234,7 @@ pub fn rgb_from_hsv((h, s, v): (f32, f32, f32)) -> [f32; 3] {
|
|||
}
|
||||
|
||||
#[test]
|
||||
#[ignore] // a bit expensive
|
||||
#[ignore = "too expensive"]
|
||||
fn test_hsv_roundtrip() {
|
||||
for r in 0..=255 {
|
||||
for g in 0..=255 {
|
||||
|
|
|
|||
|
|
@ -893,16 +893,15 @@ pub trait Storage {
|
|||
#[cfg(feature = "ron")]
|
||||
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
|
||||
profiling::function_scope!(key);
|
||||
storage
|
||||
.get_string(key)
|
||||
.and_then(|value| match ron::from_str(&value) {
|
||||
Ok(value) => Some(value),
|
||||
Err(err) => {
|
||||
// This happens on when we break the format, e.g. when updating egui.
|
||||
log::debug!("Failed to decode RON: {err}");
|
||||
None
|
||||
}
|
||||
})
|
||||
let value = storage.get_string(key)?;
|
||||
match ron::from_str(&value) {
|
||||
Ok(value) => Some(value),
|
||||
Err(err) => {
|
||||
// This happens on when we break the format, e.g. when updating egui.
|
||||
log::debug!("Failed to decode RON: {err}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Serialize the given value as [RON](https://github.com/ron-rs/ron) and store with the given key.
|
||||
|
|
|
|||
|
|
@ -336,10 +336,10 @@ impl<'app> GlowWinitApp<'app> {
|
|||
}
|
||||
|
||||
Ok(self.running.insert(GlowWinitRunning {
|
||||
glutin,
|
||||
painter,
|
||||
integration,
|
||||
app,
|
||||
glutin,
|
||||
painter,
|
||||
}))
|
||||
}
|
||||
}
|
||||
|
|
@ -362,8 +362,12 @@ impl WinitApp for GlowWinitApp<'_> {
|
|||
|
||||
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId> {
|
||||
self.running
|
||||
.as_ref()
|
||||
.and_then(|r| r.glutin.borrow().window_from_viewport.get(&id).copied())
|
||||
.as_ref()?
|
||||
.glutin
|
||||
.borrow()
|
||||
.window_from_viewport
|
||||
.get(&id)
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn save(&mut self) {
|
||||
|
|
|
|||
|
|
@ -145,7 +145,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
|||
log::error!("Exiting because of error: {err}");
|
||||
exit = true;
|
||||
self.return_result = Err(err);
|
||||
};
|
||||
}
|
||||
|
||||
if save {
|
||||
log::debug!("Received an EventResult::Save - saving app state");
|
||||
|
|
@ -176,7 +176,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
|||
.retain(|window_id, repaint_time| {
|
||||
if now < *repaint_time {
|
||||
return true; // not yet ready
|
||||
};
|
||||
}
|
||||
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
|
|
@ -192,7 +192,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
|||
let next_repaint_time = self.windows_next_repaint_times.values().min().copied();
|
||||
if let Some(next_repaint_time) = next_repaint_time {
|
||||
event_loop.set_control_flow(ControlFlow::WaitUntil(next_repaint_time));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -333,10 +333,8 @@ impl WinitApp for WgpuWinitApp<'_> {
|
|||
.as_ref()
|
||||
.and_then(|r| {
|
||||
let shared = r.shared.borrow();
|
||||
shared
|
||||
.viewport_from_window
|
||||
.get(&window_id)
|
||||
.and_then(|id| shared.viewports.get(id).map(|v| v.window.clone()))
|
||||
let id = shared.viewport_from_window.get(&window_id)?;
|
||||
shared.viewports.get(id).map(|v| v.window.clone())
|
||||
})
|
||||
.flatten()
|
||||
}
|
||||
|
|
@ -821,17 +819,16 @@ impl WgpuWinitRunning<'_> {
|
|||
}
|
||||
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
let event_response = viewport_id
|
||||
.and_then(|viewport_id| {
|
||||
shared.viewports.get_mut(&viewport_id).and_then(|viewport| {
|
||||
Some(integration.on_window_event(
|
||||
viewport.window.as_deref()?,
|
||||
viewport.egui_winit.as_mut()?,
|
||||
event,
|
||||
))
|
||||
})
|
||||
let viewport = shared.viewports.get_mut(&viewport_id)?;
|
||||
Some(integration.on_window_event(
|
||||
viewport.window.as_deref()?,
|
||||
viewport.egui_winit.as_mut()?,
|
||||
event,
|
||||
))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
|
|
|
|||
|
|
@ -873,7 +873,7 @@ impl Renderer {
|
|||
callbacks.push(c.0.as_ref());
|
||||
} else {
|
||||
log::warn!("Unknown paint callback: expected `egui_wgpu::Callback`");
|
||||
};
|
||||
}
|
||||
acc
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -328,7 +328,7 @@ impl Painter {
|
|||
})
|
||||
.create_view(&wgpu::TextureViewDescriptor::default()),
|
||||
);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
pub fn on_window_resized(
|
||||
|
|
|
|||
|
|
@ -372,7 +372,7 @@ impl State {
|
|||
winit::event::Ime::Disabled | winit::event::Ime::Preedit(_, None) => {
|
||||
self.ime_event_disable();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
EventResponse {
|
||||
repaint: true,
|
||||
|
|
@ -583,7 +583,7 @@ impl State {
|
|||
pos,
|
||||
force: None,
|
||||
});
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -458,7 +458,7 @@ impl<'a> Popup<'a> {
|
|||
|
||||
/// Get the expected size of the popup.
|
||||
pub fn get_expected_size(&self) -> Option<Vec2> {
|
||||
AreaState::load(&self.ctx, self.id).and_then(|area| area.size)
|
||||
AreaState::load(&self.ctx, self.id)?.size
|
||||
}
|
||||
|
||||
/// Calculate the best alignment for the popup, based on the last size and screen rect.
|
||||
|
|
|
|||
|
|
@ -1059,7 +1059,7 @@ impl Prepared {
|
|||
|
||||
delta += delta_update;
|
||||
animation = animation_update;
|
||||
};
|
||||
}
|
||||
|
||||
if delta != 0.0 {
|
||||
let target_offset = state.offset[d] + delta;
|
||||
|
|
@ -1090,7 +1090,7 @@ impl Prepared {
|
|||
for d in 0..2 {
|
||||
if saved_scroll_target[d].is_some() {
|
||||
state.scroll_target[d] = saved_scroll_target[d].clone();
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
|||
|
|
@ -616,7 +616,7 @@ impl Window<'_> {
|
|||
*where_to_put_header_background,
|
||||
RectShape::filled(title_bar.inner_rect, round, header_color),
|
||||
);
|
||||
};
|
||||
}
|
||||
|
||||
if false {
|
||||
ctx.debug_painter().debug_rect(
|
||||
|
|
|
|||
|
|
@ -1259,7 +1259,7 @@ impl Context {
|
|||
viewport.this_pass.scroll_delta.0 += DISTANCE * Vec2::RIGHT;
|
||||
}
|
||||
_ => return false,
|
||||
};
|
||||
}
|
||||
true
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -729,7 +729,7 @@ impl WidgetInfo {
|
|||
description = format!("{state} {description}");
|
||||
} else {
|
||||
description += if *selected { "selected" } else { "" };
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(label) = label {
|
||||
|
|
|
|||
|
|
@ -293,7 +293,7 @@ pub(crate) fn interact(
|
|||
drag_started,
|
||||
dragged,
|
||||
drag_stopped,
|
||||
contains_pointer,
|
||||
hovered,
|
||||
contains_pointer,
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -753,7 +753,7 @@ impl Layout {
|
|||
pos2(frame_rect.max.x, f32::NAN),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// Make sure we also expand where we consider adding things (the cursor):
|
||||
|
|
@ -779,7 +779,7 @@ impl Layout {
|
|||
Direction::BottomUp => {
|
||||
cursor.max.y = widget_rect.min.y - item_spacing.y;
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/// Move to the next row in a wrapping layout.
|
||||
|
|
|
|||
|
|
@ -802,15 +802,12 @@ impl Memory {
|
|||
|
||||
/// Top-most layer at the given position.
|
||||
pub fn layer_id_at(&self, pos: Pos2) -> Option<LayerId> {
|
||||
self.areas()
|
||||
.layer_id_at(pos, &self.to_global)
|
||||
.and_then(|layer_id| {
|
||||
if self.is_above_modal_layer(layer_id) {
|
||||
Some(layer_id)
|
||||
} else {
|
||||
self.top_modal_layer()
|
||||
}
|
||||
})
|
||||
let layer_id = self.areas().layer_id_at(pos, &self.to_global)?;
|
||||
if self.is_above_modal_layer(layer_id) {
|
||||
Some(layer_id)
|
||||
} else {
|
||||
self.top_modal_layer()
|
||||
}
|
||||
}
|
||||
|
||||
/// The currently set transform of a layer.
|
||||
|
|
@ -855,7 +852,7 @@ impl Memory {
|
|||
|
||||
/// Which widget has keyboard focus?
|
||||
pub fn focused(&self) -> Option<Id> {
|
||||
self.focus().and_then(|f| f.focused())
|
||||
self.focus()?.focused()
|
||||
}
|
||||
|
||||
/// Set an event filter for a widget.
|
||||
|
|
@ -1066,9 +1063,8 @@ impl Memory {
|
|||
/// Get the position for this popup.
|
||||
#[deprecated = "Use Popup::position_of_id instead"]
|
||||
pub fn popup_position(&self, id: Id) -> Option<Pos2> {
|
||||
self.popups
|
||||
.get(&self.viewport_id)
|
||||
.and_then(|state| if state.id == id { state.pos } else { None })
|
||||
let state = self.popups.get(&self.viewport_id)?;
|
||||
if state.id == id { state.pos } else { None }
|
||||
}
|
||||
|
||||
/// Close any currently open popup.
|
||||
|
|
|
|||
|
|
@ -766,9 +766,8 @@ impl MenuState {
|
|||
}
|
||||
|
||||
fn submenu(&self, id: Id) -> Option<&Arc<RwLock<Self>>> {
|
||||
self.sub_menu
|
||||
.as_ref()
|
||||
.and_then(|(k, sub)| if id == *k { Some(sub) } else { None })
|
||||
let (k, sub) = self.sub_menu.as_ref()?;
|
||||
if id == *k { Some(sub) } else { None }
|
||||
}
|
||||
|
||||
/// Open submenu at position, if not already open.
|
||||
|
|
|
|||
|
|
@ -2136,7 +2136,7 @@ impl Visuals {
|
|||
ui.color_edit_button_srgba(color);
|
||||
} else {
|
||||
*color = None;
|
||||
};
|
||||
}
|
||||
});
|
||||
|
||||
ui.end_row();
|
||||
|
|
|
|||
|
|
@ -325,7 +325,7 @@ impl<'a> Button<'a> {
|
|||
.fill(fill)
|
||||
.stroke(stroke)
|
||||
.corner_radius(corner_radius.unwrap_or(visuals.corner_radius));
|
||||
};
|
||||
}
|
||||
|
||||
prepared.paint(ui)
|
||||
} else {
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ impl Label {
|
|||
} else {
|
||||
layout_job.halign = self.halign.unwrap_or(ui.layout().horizontal_placement());
|
||||
layout_job.justify = ui.layout().horizontal_justify();
|
||||
};
|
||||
}
|
||||
|
||||
let galley = ui.fonts(|fonts| fonts.layout_job(layout_job));
|
||||
let (rect, mut response) = ui.allocate_exact_size(galley.size(), sense);
|
||||
|
|
|
|||
|
|
@ -806,7 +806,7 @@ impl Slider<'_> {
|
|||
SliderOrientation::Vertical => {
|
||||
trailing_rail_rect.min.y = center.y - corner_radius.se as f32;
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
ui.painter().rect_filled(
|
||||
trailing_rail_rect,
|
||||
|
|
@ -936,7 +936,7 @@ impl Slider<'_> {
|
|||
|
||||
if let Some(fmt) = &self.custom_formatter {
|
||||
dv = dv.custom_formatter(fmt);
|
||||
};
|
||||
}
|
||||
if let Some(parser) = &self.custom_parser {
|
||||
dv = dv.custom_parser(parser);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -73,7 +73,7 @@ impl FractalClock {
|
|||
));
|
||||
} else {
|
||||
ui.label("The fractal_clock clock is not showing the correct time");
|
||||
};
|
||||
}
|
||||
ui.label(format!("Painted line count: {}", self.line_count));
|
||||
|
||||
ui.checkbox(&mut self.paused, "Paused");
|
||||
|
|
|
|||
|
|
@ -61,7 +61,7 @@ impl eframe::App for ImageViewer {
|
|||
ctx.forget_image(&self.current_uri);
|
||||
self.uri_edit_text = self.uri_edit_text.trim().to_owned();
|
||||
self.current_uri = self.uri_edit_text.clone();
|
||||
};
|
||||
}
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
if ui.button("file…").clicked() {
|
||||
|
|
|
|||
|
|
@ -91,5 +91,5 @@ fn start_puffin_server() {
|
|||
Err(err) => {
|
||||
log::error!("Failed to start puffin server: {err}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -805,7 +805,7 @@ impl TextRotation {
|
|||
if let egui::epaint::Shape::Text(ts) = &mut t {
|
||||
let new = ts.clone().with_angle_and_anchor(self.angle, self.align);
|
||||
*ts = new;
|
||||
};
|
||||
}
|
||||
|
||||
t
|
||||
});
|
||||
|
|
@ -814,7 +814,7 @@ impl TextRotation {
|
|||
let align_pt =
|
||||
rect.min + start_pos + self.align.pos_in_rect(&ts.galley.rect).to_vec2();
|
||||
painter.circle(align_pt, 2.0, Color32::RED, (0.0, Color32::RED));
|
||||
};
|
||||
}
|
||||
|
||||
painter.rect(
|
||||
rect,
|
||||
|
|
|
|||
|
|
@ -152,7 +152,7 @@ impl PaintBezier {
|
|||
_ => {
|
||||
unreachable!();
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
painter.add(PathShape::line(points_in_screen, self.aux_stroke));
|
||||
painter.extend(control_point_shapes);
|
||||
|
|
|
|||
|
|
@ -165,7 +165,7 @@ fn shortcuts(ui: &Ui, code: &mut dyn TextBuffer, ccursor_range: &mut CCursorRang
|
|||
if ui.input_mut(|i| i.consume_shortcut(&shortcut)) {
|
||||
any_change = true;
|
||||
toggle_surrounding(code, ccursor_range, surrounding);
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
any_change
|
||||
|
|
|
|||
|
|
@ -101,7 +101,7 @@ pub fn item_ui(ui: &mut Ui, item: easy_mark::Item<'_>) {
|
|||
Shape::rect_filled(rect, 1.0, code_bg_color),
|
||||
);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn rich_text_from_style(text: &str, style: &easy_mark::Style) -> RichText {
|
||||
|
|
|
|||
|
|
@ -336,7 +336,7 @@ impl DatePickerPopup<'_> {
|
|||
if day.month() != popup_state.month {
|
||||
text_color =
|
||||
text_color.linear_multiply(0.5);
|
||||
};
|
||||
}
|
||||
|
||||
let button_response = ui.add(
|
||||
Button::new(
|
||||
|
|
|
|||
|
|
@ -528,7 +528,7 @@ impl Painter {
|
|||
|
||||
self.upload_texture_srgb(delta.pos, image.size, delta.options, data);
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
fn upload_texture_srgb(
|
||||
|
|
|
|||
|
|
@ -232,7 +232,8 @@ impl Display for SnapshotError {
|
|||
let diff_path = std::path::absolute(diff_path).unwrap_or(diff_path.clone());
|
||||
write!(
|
||||
f,
|
||||
"'{name}' Image did not match snapshot. Diff: {diff}, {diff_path:?}. {HOW_TO_UPDATE_SCREENSHOTS}"
|
||||
"'{name}' Image did not match snapshot. Diff: {diff}, {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||
diff_path.display()
|
||||
)
|
||||
}
|
||||
Self::OpenSnapshot { path, err } => {
|
||||
|
|
@ -240,19 +241,25 @@ impl Display for SnapshotError {
|
|||
match err {
|
||||
ImageError::IoError(io) => match io.kind() {
|
||||
ErrorKind::NotFound => {
|
||||
write!(f, "Missing snapshot: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}")
|
||||
write!(
|
||||
f,
|
||||
"Missing snapshot: {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||
path.display()
|
||||
)
|
||||
}
|
||||
err => {
|
||||
write!(
|
||||
f,
|
||||
"Error reading snapshot: {err:?}\nAt: {path:?}. {HOW_TO_UPDATE_SCREENSHOTS}"
|
||||
"Error reading snapshot: {err:?}\nAt: {}. {HOW_TO_UPDATE_SCREENSHOTS}",
|
||||
path.display()
|
||||
)
|
||||
}
|
||||
},
|
||||
err => {
|
||||
write!(
|
||||
f,
|
||||
"Error decoding snapshot: {err:?}\nAt: {path:?}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr"
|
||||
"Error decoding snapshot: {err:?}\nAt: {}. Make sure git-lfs is setup correctly. Read the instructions here: https://github.com/emilk/egui/blob/main/CONTRIBUTING.md#making-a-pr",
|
||||
path.display()
|
||||
)
|
||||
}
|
||||
}
|
||||
|
|
@ -269,7 +276,7 @@ impl Display for SnapshotError {
|
|||
}
|
||||
Self::WriteSnapshot { path, err } => {
|
||||
let path = std::path::absolute(path).unwrap_or(path.clone());
|
||||
write!(f, "Error writing snapshot: {err:?}\nAt: {path:?}")
|
||||
write!(f, "Error writing snapshot: {err:?}\nAt: {}", path.display())
|
||||
}
|
||||
Self::RenderError { err } => {
|
||||
write!(f, "Error rendering image: {err:?}")
|
||||
|
|
@ -363,7 +370,7 @@ fn try_image_snapshot_options_impl(
|
|||
// No need for an explicit `.new` file:
|
||||
std::fs::remove_file(&new_path).ok();
|
||||
|
||||
println!("Updated snapshot: {snapshot_path:?}");
|
||||
println!("Updated snapshot: {}", snapshot_path.display());
|
||||
|
||||
Ok(())
|
||||
};
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ impl TestMenu {
|
|||
.clicked()
|
||||
{
|
||||
ui.close();
|
||||
};
|
||||
}
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -93,7 +93,7 @@ fn test_scroll_harness() -> Harness<'static, bool> {
|
|||
}
|
||||
if ui.button("Hidden Button").clicked() {
|
||||
*state = true;
|
||||
};
|
||||
}
|
||||
});
|
||||
},
|
||||
false,
|
||||
|
|
|
|||
|
|
@ -134,7 +134,7 @@ impl Align {
|
|||
if size == f32::INFINITY {
|
||||
Rangef::new(f32::NEG_INFINITY, f32::INFINITY)
|
||||
} else {
|
||||
let left = (min + max) / 2.0 - size / 2.0;
|
||||
let left = f32::midpoint(min, max) - size / 2.0;
|
||||
Rangef::new(left, left + size)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -331,8 +331,8 @@ impl Rect {
|
|||
#[inline(always)]
|
||||
pub fn center(&self) -> Pos2 {
|
||||
Pos2 {
|
||||
x: (self.min.x + self.max.x) / 2.0,
|
||||
y: (self.min.y + self.max.y) / 2.0,
|
||||
x: f32::midpoint(self.min.x, self.max.x),
|
||||
y: f32::midpoint(self.min.y, self.max.y),
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -43,7 +43,7 @@ pub fn best_in_range_f64(min: f64, max: f64) -> f64 {
|
|||
|
||||
if min_exponent.floor() != max_exponent.floor() {
|
||||
// pick the geometric center of the two:
|
||||
let exponent = (min_exponent + max_exponent) / 2.0;
|
||||
let exponent = f64::midpoint(min_exponent, max_exponent);
|
||||
return 10.0_f64.powi(exponent.round() as i32);
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -36,8 +36,8 @@ impl TSTransform {
|
|||
/// `(0, 0)`, then translates them.
|
||||
pub fn new(translation: Vec2, scaling: f32) -> Self {
|
||||
Self {
|
||||
translation,
|
||||
scaling,
|
||||
translation,
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -177,5 +177,5 @@ fn start_puffin_server() {
|
|||
Err(err) => {
|
||||
log::error!("Failed to start puffin server: {err}");
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ impl eframe::App for MyApp {
|
|||
ctx.set_theme(egui::Theme::Dark);
|
||||
} else {
|
||||
ctx.set_theme(egui::Theme::Light);
|
||||
};
|
||||
}
|
||||
ctx.send_viewport_cmd(
|
||||
egui::ViewportCommand::Screenshot(Default::default()),
|
||||
);
|
||||
|
|
|
|||
|
|
@ -32,7 +32,7 @@ pub fn ask_to_run(mut cmd: Command, ask: bool, reason: &str) -> Result<(), DynEr
|
|||
"" | "y" | "yes" => {}
|
||||
"n" | "no" => return Err("Aborting as per your request".into()),
|
||||
a => return Err(format!("Invalid answer `{a}`").into()),
|
||||
};
|
||||
}
|
||||
} else {
|
||||
println!("Running `{cmd:?}` to {reason}.");
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue