mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 13:50:04 -04:00
Increase MSRV to 1.67 (#3234)
* Bump MSRV to 1.67 * clippy fixes * cargo clippy: inline format args * Add `clippy::uninlined_format_args` to cranky lints * Fix clippy on wasm * More clippy fixes
This commit is contained in:
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "An easy-to-use immediate mode GUI that runs on both web and native"
|
||||
edition = "2021"
|
||||
rust-version = "1.65"
|
||||
rust-version = "1.67"
|
||||
homepage = "https://github.com/emilk/egui"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "../../README.md"
|
||||
|
||||
@@ -566,7 +566,7 @@ impl Context {
|
||||
}
|
||||
|
||||
let show_error = |widget_rect: Rect, text: String| {
|
||||
let text = format!("🔥 {}", text);
|
||||
let text = format!("🔥 {text}");
|
||||
let color = self.style().visuals.error_fg_color;
|
||||
let painter = self.debug_painter();
|
||||
painter.rect_stroke(widget_rect, 0.0, (1.0, color));
|
||||
@@ -612,10 +612,10 @@ impl Context {
|
||||
let id_str = id.short_debug_format();
|
||||
|
||||
if prev_rect.min.distance(new_rect.min) < 4.0 {
|
||||
show_error(new_rect, format!("Double use of {} ID {}", what, id_str));
|
||||
show_error(new_rect, format!("Double use of {what} ID {id_str}"));
|
||||
} else {
|
||||
show_error(prev_rect, format!("First use of {} ID {}", what, id_str));
|
||||
show_error(new_rect, format!("Second use of {} ID {}", what, id_str));
|
||||
show_error(prev_rect, format!("First use of {what} ID {id_str}"));
|
||||
show_error(new_rect, format!("Second use of {what} ID {id_str}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1574,14 +1574,14 @@ impl Context {
|
||||
|
||||
let pointer_pos = self
|
||||
.pointer_hover_pos()
|
||||
.map_or_else(String::new, |pos| format!("{:?}", pos));
|
||||
ui.label(format!("Pointer pos: {}", pointer_pos));
|
||||
.map_or_else(String::new, |pos| format!("{pos:?}"));
|
||||
ui.label(format!("Pointer pos: {pointer_pos}"));
|
||||
|
||||
let top_layer = self
|
||||
.pointer_hover_pos()
|
||||
.and_then(|pos| self.layer_id_at(pos))
|
||||
.map_or_else(String::new, |layer| layer.short_debug_format());
|
||||
ui.label(format!("Top layer under mouse: {}", top_layer));
|
||||
ui.label(format!("Top layer under mouse: {top_layer}"));
|
||||
|
||||
ui.add_space(16.0);
|
||||
|
||||
@@ -1667,7 +1667,7 @@ impl Context {
|
||||
ui.image(texture_id, size);
|
||||
});
|
||||
|
||||
ui.label(format!("{} x {}", w, h));
|
||||
ui.label(format!("{w} x {h}"));
|
||||
ui.label(format!("{:.3} MB", meta.bytes_used() as f64 * 1e-6));
|
||||
ui.label(format!("{:?}", meta.name));
|
||||
ui.end_row();
|
||||
@@ -1688,8 +1688,7 @@ impl Context {
|
||||
|
||||
let (num_state, num_serialized) = self.data(|d| (d.len(), d.count_serialized()));
|
||||
ui.label(format!(
|
||||
"{} widget states stored (of which {} are serialized).",
|
||||
num_state, num_serialized
|
||||
"{num_state} widget states stored (of which {num_serialized} are serialized)."
|
||||
));
|
||||
|
||||
ui.horizontal(|ui| {
|
||||
|
||||
@@ -937,25 +937,25 @@ impl RawInput {
|
||||
focused,
|
||||
} = self;
|
||||
|
||||
ui.label(format!("screen_rect: {:?} points", screen_rect));
|
||||
ui.label(format!("pixels_per_point: {:?}", pixels_per_point))
|
||||
ui.label(format!("screen_rect: {screen_rect:?} points"));
|
||||
ui.label(format!("pixels_per_point: {pixels_per_point:?}"))
|
||||
.on_hover_text(
|
||||
"Also called HDPI factor.\nNumber of physical pixels per each logical pixel.",
|
||||
);
|
||||
ui.label(format!("max_texture_side: {:?}", max_texture_side));
|
||||
ui.label(format!("max_texture_side: {max_texture_side:?}"));
|
||||
if let Some(time) = time {
|
||||
ui.label(format!("time: {:.3} s", time));
|
||||
ui.label(format!("time: {time:.3} s"));
|
||||
} else {
|
||||
ui.label("time: None");
|
||||
}
|
||||
ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt));
|
||||
ui.label(format!("modifiers: {:#?}", modifiers));
|
||||
ui.label(format!("modifiers: {modifiers:#?}"));
|
||||
ui.label(format!("hovered_files: {}", hovered_files.len()));
|
||||
ui.label(format!("dropped_files: {}", dropped_files.len()));
|
||||
ui.label(format!("focused: {}", focused));
|
||||
ui.label(format!("focused: {focused}"));
|
||||
ui.scope(|ui| {
|
||||
ui.set_min_height(150.0);
|
||||
ui.label(format!("events: {:#?}", events))
|
||||
ui.label(format!("events: {events:#?}"))
|
||||
.on_hover_text("key presses etc");
|
||||
});
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ impl PlatformOutput {
|
||||
/// This can be used by a text-to-speech system to describe the events (if any).
|
||||
pub fn events_description(&self) -> String {
|
||||
// only describe last event:
|
||||
if let Some(event) = self.events.iter().rev().next() {
|
||||
if let Some(event) = self.events.iter().next_back() {
|
||||
match event {
|
||||
OutputEvent::Clicked(widget_info)
|
||||
| OutputEvent::DoubleClicked(widget_info)
|
||||
@@ -417,12 +417,12 @@ impl OutputEvent {
|
||||
impl std::fmt::Debug for OutputEvent {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
match self {
|
||||
Self::Clicked(wi) => write!(f, "Clicked({:?})", wi),
|
||||
Self::DoubleClicked(wi) => write!(f, "DoubleClicked({:?})", wi),
|
||||
Self::TripleClicked(wi) => write!(f, "TripleClicked({:?})", wi),
|
||||
Self::FocusGained(wi) => write!(f, "FocusGained({:?})", wi),
|
||||
Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({:?})", wi),
|
||||
Self::ValueChanged(wi) => write!(f, "ValueChanged({:?})", wi),
|
||||
Self::Clicked(wi) => write!(f, "Clicked({wi:?})"),
|
||||
Self::DoubleClicked(wi) => write!(f, "DoubleClicked({wi:?})"),
|
||||
Self::TripleClicked(wi) => write!(f, "TripleClicked({wi:?})"),
|
||||
Self::FocusGained(wi) => write!(f, "FocusGained({wi:?})"),
|
||||
Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({wi:?})"),
|
||||
Self::ValueChanged(wi) => write!(f, "ValueChanged({wi:?})"),
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -609,14 +609,14 @@ impl WidgetInfo {
|
||||
if let Some(selected) = selected {
|
||||
if *typ == WidgetType::Checkbox {
|
||||
let state = if *selected { "checked" } else { "unchecked" };
|
||||
description = format!("{} {}", state, description);
|
||||
description = format!("{state} {description}");
|
||||
} else {
|
||||
description += if *selected { "selected" } else { "" };
|
||||
};
|
||||
}
|
||||
|
||||
if let Some(label) = label {
|
||||
description = format!("{}: {}", label, description);
|
||||
description = format!("{label}: {description}");
|
||||
}
|
||||
|
||||
if typ == &WidgetType::TextEdit {
|
||||
@@ -630,7 +630,7 @@ impl WidgetInfo {
|
||||
} else {
|
||||
text = "blank".into();
|
||||
}
|
||||
description = format!("{}: {}", text, description);
|
||||
description = format!("{text}: {description}");
|
||||
}
|
||||
|
||||
if let Some(value) = value {
|
||||
|
||||
@@ -990,30 +990,28 @@ impl InputState {
|
||||
});
|
||||
}
|
||||
|
||||
ui.label(format!("scroll_delta: {:?} points", scroll_delta));
|
||||
ui.label(format!("zoom_factor_delta: {:4.2}x", zoom_factor_delta));
|
||||
ui.label(format!("screen_rect: {:?} points", screen_rect));
|
||||
ui.label(format!("scroll_delta: {scroll_delta:?} points"));
|
||||
ui.label(format!("zoom_factor_delta: {zoom_factor_delta:4.2}x"));
|
||||
ui.label(format!("screen_rect: {screen_rect:?} points"));
|
||||
ui.label(format!(
|
||||
"{} physical pixels for each logical point",
|
||||
pixels_per_point
|
||||
"{pixels_per_point} physical pixels for each logical point"
|
||||
));
|
||||
ui.label(format!(
|
||||
"max texture size (on each side): {}",
|
||||
max_texture_side
|
||||
"max texture size (on each side): {max_texture_side}"
|
||||
));
|
||||
ui.label(format!("time: {:.3} s", time));
|
||||
ui.label(format!("time: {time:.3} s"));
|
||||
ui.label(format!(
|
||||
"time since previous frame: {:.1} ms",
|
||||
1e3 * unstable_dt
|
||||
));
|
||||
ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt));
|
||||
ui.label(format!("stable_dt: {:.1} ms", 1e3 * stable_dt));
|
||||
ui.label(format!("focused: {}", focused));
|
||||
ui.label(format!("modifiers: {:#?}", modifiers));
|
||||
ui.label(format!("keys_down: {:?}", keys_down));
|
||||
ui.label(format!("focused: {focused}"));
|
||||
ui.label(format!("modifiers: {modifiers:#?}"));
|
||||
ui.label(format!("keys_down: {keys_down:?}"));
|
||||
ui.scope(|ui| {
|
||||
ui.set_min_height(150.0);
|
||||
ui.label(format!("events: {:#?}", events))
|
||||
ui.label(format!("events: {events:#?}"))
|
||||
.on_hover_text("key presses etc");
|
||||
});
|
||||
}
|
||||
@@ -1037,22 +1035,21 @@ impl PointerState {
|
||||
pointer_events,
|
||||
} = self;
|
||||
|
||||
ui.label(format!("latest_pos: {:?}", latest_pos));
|
||||
ui.label(format!("interact_pos: {:?}", interact_pos));
|
||||
ui.label(format!("delta: {:?}", delta));
|
||||
ui.label(format!("latest_pos: {latest_pos:?}"));
|
||||
ui.label(format!("interact_pos: {interact_pos:?}"));
|
||||
ui.label(format!("delta: {delta:?}"));
|
||||
ui.label(format!(
|
||||
"velocity: [{:3.0} {:3.0}] points/sec",
|
||||
velocity.x, velocity.y
|
||||
));
|
||||
ui.label(format!("down: {:#?}", down));
|
||||
ui.label(format!("press_origin: {:?}", press_origin));
|
||||
ui.label(format!("press_start_time: {:?} s", press_start_time));
|
||||
ui.label(format!("down: {down:#?}"));
|
||||
ui.label(format!("press_origin: {press_origin:?}"));
|
||||
ui.label(format!("press_start_time: {press_start_time:?} s"));
|
||||
ui.label(format!(
|
||||
"has_moved_too_much_for_a_click: {}",
|
||||
has_moved_too_much_for_a_click
|
||||
"has_moved_too_much_for_a_click: {has_moved_too_much_for_a_click}"
|
||||
));
|
||||
ui.label(format!("last_click_time: {:#?}", last_click_time));
|
||||
ui.label(format!("last_last_click_time: {:#?}", last_last_click_time));
|
||||
ui.label(format!("pointer_events: {:?}", pointer_events));
|
||||
ui.label(format!("last_click_time: {last_click_time:#?}"));
|
||||
ui.label(format!("last_last_click_time: {last_last_click_time:#?}"));
|
||||
ui.label(format!("pointer_events: {pointer_events:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -286,7 +286,7 @@ impl TouchState {
|
||||
|
||||
impl TouchState {
|
||||
pub fn ui(&self, ui: &mut crate::Ui) {
|
||||
ui.label(format!("{:?}", self));
|
||||
ui.label(format!("{self:?}"));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -294,7 +294,7 @@ impl Debug for TouchState {
|
||||
// This outputs less clutter than `#[derive(Debug)]`:
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
for (id, touch) in &self.active_touches {
|
||||
f.write_fmt(format_args!("#{:?}: {:#?}\n", id, touch))?;
|
||||
f.write_fmt(format_args!("#{id:?}: {touch:#?}\n"))?;
|
||||
}
|
||||
f.write_fmt(format_args!("gesture: {:#?}\n", self.gesture_state))?;
|
||||
Ok(())
|
||||
|
||||
@@ -31,10 +31,7 @@ pub(crate) fn font_texture_ui(ui: &mut Ui, [width, height]: [usize; 2]) -> Respo
|
||||
Color32::BLACK
|
||||
};
|
||||
|
||||
ui.label(format!(
|
||||
"Texture size: {} x {} (hover to zoom)",
|
||||
width, height
|
||||
));
|
||||
ui.label(format!("Texture size: {width} x {height} (hover to zoom)"));
|
||||
if width <= 1 || height <= 1 {
|
||||
return;
|
||||
}
|
||||
@@ -108,7 +105,7 @@ impl Widget for &epaint::stats::PaintStats {
|
||||
label(ui, shape_path, "paths");
|
||||
label(ui, shape_mesh, "nested meshes");
|
||||
label(ui, shape_vec, "nested shapes");
|
||||
ui.label(format!("{:6} callbacks", num_callbacks));
|
||||
ui.label(format!("{num_callbacks:6} callbacks"));
|
||||
ui.add_space(10.0);
|
||||
|
||||
ui.label("Text shapes:");
|
||||
|
||||
@@ -226,7 +226,7 @@ impl Painter {
|
||||
|
||||
pub fn error(&self, pos: Pos2, text: impl std::fmt::Display) -> Rect {
|
||||
let color = self.ctx.style().visuals.error_fg_color;
|
||||
self.debug_text(pos, Align2::LEFT_TOP, color, format!("🔥 {}", text))
|
||||
self.debug_text(pos, Align2::LEFT_TOP, color, format!("🔥 {text}"))
|
||||
}
|
||||
|
||||
/// text with a background
|
||||
|
||||
@@ -234,17 +234,17 @@ fn color_text_ui(ui: &mut Ui, color: impl Into<Color32>, alpha: Alpha) {
|
||||
|
||||
if ui.button("📋").on_hover_text("Click to copy").clicked() {
|
||||
if alpha == Alpha::Opaque {
|
||||
ui.output_mut(|o| o.copied_text = format!("{}, {}, {}", r, g, b));
|
||||
ui.output_mut(|o| o.copied_text = format!("{r}, {g}, {b}"));
|
||||
} else {
|
||||
ui.output_mut(|o| o.copied_text = format!("{}, {}, {}, {}", r, g, b, a));
|
||||
ui.output_mut(|o| o.copied_text = format!("{r}, {g}, {b}, {a}"));
|
||||
}
|
||||
}
|
||||
|
||||
if alpha == Alpha::Opaque {
|
||||
ui.label(format!("rgb({}, {}, {})", r, g, b))
|
||||
ui.label(format!("rgb({r}, {g}, {b})"))
|
||||
.on_hover_text("Red Green Blue");
|
||||
} else {
|
||||
ui.label(format!("rgba({}, {}, {}, {})", r, g, b, a))
|
||||
ui.label(format!("rgba({r}, {g}, {b}, {a})"))
|
||||
.on_hover_text("Red Green Blue with premultiplied Alpha");
|
||||
}
|
||||
});
|
||||
|
||||
@@ -627,7 +627,7 @@ impl<'a> Widget for DragValue<'a> {
|
||||
// The value is exposed as a string by the text edit widget
|
||||
// when in edit mode.
|
||||
if !is_kb_editing {
|
||||
let value_text = format!("{}{}{}", prefix, value_text, suffix);
|
||||
let value_text = format!("{prefix}{value_text}{suffix}");
|
||||
builder.set_value(value_text);
|
||||
}
|
||||
});
|
||||
|
||||
@@ -1732,7 +1732,7 @@ pub(super) fn rulers_at_value(
|
||||
let mut prefix = String::new();
|
||||
|
||||
if !name.is_empty() {
|
||||
prefix = format!("{}\n", name);
|
||||
prefix = format!("{name}\n");
|
||||
}
|
||||
|
||||
let text = {
|
||||
|
||||
@@ -125,8 +125,8 @@ impl ToString for LineStyle {
|
||||
fn to_string(&self) -> String {
|
||||
match self {
|
||||
LineStyle::Solid => "Solid".into(),
|
||||
LineStyle::Dotted { spacing } => format!("Dotted{}Px", spacing),
|
||||
LineStyle::Dashed { length } => format!("Dashed{}Px", length),
|
||||
LineStyle::Dotted { spacing } => format!("Dotted{spacing}Px"),
|
||||
LineStyle::Dashed { length } => format!("Dashed{length}Px"),
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1453,7 +1453,7 @@ impl PreparedPlot {
|
||||
let axis_range = match axis {
|
||||
0 => bounds.range_x(),
|
||||
1 => bounds.range_y(),
|
||||
_ => panic!("Axis {} does not exist.", axis),
|
||||
_ => panic!("Axis {axis} does not exist."),
|
||||
};
|
||||
|
||||
let font_id = TextStyle::Body.resolve(ui.style());
|
||||
@@ -1676,7 +1676,7 @@ pub fn format_number(number: f64, num_decimals: usize) -> String {
|
||||
let is_integral = number as i64 as f64 == number;
|
||||
if is_integral {
|
||||
// perfect integer - show it as such:
|
||||
format!("{:.0}", number)
|
||||
format!("{number:.0}")
|
||||
} else {
|
||||
// make sure we tell the user it is not an integer by always showing a decimal or two:
|
||||
format!("{:.*}", num_decimals.at_least(1), number)
|
||||
|
||||
Reference in New Issue
Block a user