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:
Emil Ernerfeldt 2023-08-11 13:54:02 +02:00 committed by GitHub
parent bdeae9e959
commit 08fb447fb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
84 changed files with 166 additions and 193 deletions

View File

@ -19,7 +19,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master - uses: dtolnay/rust-toolchain@master
with: with:
toolchain: 1.65.0 toolchain: 1.67.0
- name: Install packages (Linux) - name: Install packages (Linux)
if: runner.os == 'Linux' if: runner.os == 'Linux'
@ -87,7 +87,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master - uses: dtolnay/rust-toolchain@master
with: with:
toolchain: 1.65.0 toolchain: 1.67.0
targets: wasm32-unknown-unknown targets: wasm32-unknown-unknown
- run: sudo apt-get update && sudo apt-get install libgtk-3-dev - run: sudo apt-get update && sudo apt-get install libgtk-3-dev
@ -145,7 +145,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: EmbarkStudios/cargo-deny-action@v1 - uses: EmbarkStudios/cargo-deny-action@v1
with: with:
rust-version: "1.65.0" rust-version: "1.67.0"
log-level: error log-level: error
command: check command: check
arguments: --target ${{ matrix.target }} arguments: --target ${{ matrix.target }}
@ -160,7 +160,7 @@ jobs:
- uses: dtolnay/rust-toolchain@master - uses: dtolnay/rust-toolchain@master
with: with:
toolchain: 1.65.0 toolchain: 1.67.0
targets: aarch64-linux-android targets: aarch64-linux-android
- name: Set up cargo cache - name: Set up cargo cache
@ -178,7 +178,7 @@ jobs:
- uses: actions/checkout@v3 - uses: actions/checkout@v3
- uses: dtolnay/rust-toolchain@master - uses: dtolnay/rust-toolchain@master
with: with:
toolchain: 1.65.0 toolchain: 1.67.0
- name: Set up cargo cache - name: Set up cargo cache
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2

View File

@ -91,6 +91,7 @@ warn = [
"clippy::trailing_empty_array", "clippy::trailing_empty_array",
"clippy::trait_duplication_in_bounds", "clippy::trait_duplication_in_bounds",
"clippy::unimplemented", "clippy::unimplemented",
"clippy::uninlined_format_args",
"clippy::unnecessary_wraps", "clippy::unnecessary_wraps",
"clippy::unnested_or_patterns", "clippy::unnested_or_patterns",
"clippy::unused_peekable", "clippy::unused_peekable",

View File

@ -1,6 +1,6 @@
# There is also a scripts/clippy_wasm/clippy.toml which forbids some mthods that are not available in wasm. # There is also a scripts/clippy_wasm/clippy.toml which forbids some mthods that are not available in wasm.
msrv = "1.65" msrv = "1.67"
# Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown # Allow-list of words for markdown in dosctrings https://rust-lang.github.io/rust-clippy/master/index.html#doc_markdown
doc-valid-idents = [ doc-valid-idents = [

View File

@ -7,7 +7,7 @@ authors = [
] ]
description = "Color structs and color conversion utilities" description = "Color structs and color conversion utilities"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "egui framework - write GUI apps that compiles to web and/or natively" description = "egui framework - write GUI apps that compiles to web and/or natively"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/eframe" homepage = "https://github.com/emilk/egui/tree/master/crates/eframe"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -708,7 +708,7 @@ mod glow_integration {
let painter = let painter =
egui_glow::Painter::new(gl.clone(), "", self.native_options.shader_version) egui_glow::Painter::new(gl.clone(), "", self.native_options.shader_version)
.unwrap_or_else(|error| panic!("some OpenGL error occurred {}\n", error)); .unwrap_or_else(|err| panic!("An OpenGL error occurred: {err}\n"));
let system_theme = system_theme(gl_window.window(), &self.native_options); let system_theme = system_theme(gl_window.window(), &self.native_options);
let mut integration = epi_integration::EpiIntegration::new( let mut integration = epi_integration::EpiIntegration::new(

View File

@ -104,7 +104,7 @@ pub fn canvas_element(canvas_id: &str) -> Option<web_sys::HtmlCanvasElement> {
pub fn canvas_element_or_die(canvas_id: &str) -> web_sys::HtmlCanvasElement { pub fn canvas_element_or_die(canvas_id: &str) -> web_sys::HtmlCanvasElement {
canvas_element(canvas_id) canvas_element(canvas_id)
.unwrap_or_else(|| panic!("Failed to find canvas with id {:?}", canvas_id)) .unwrap_or_else(|| panic!("Failed to find canvas with id {canvas_id:?}"))
} }
fn canvas_origin(canvas_id: &str) -> egui::Pos2 { fn canvas_origin(canvas_id: &str) -> egui::Pos2 {

View File

@ -104,8 +104,7 @@ pub fn install_text_agent(runner_ref: &WebRunner) -> Result<(), JsValue> {
runner_ref.add_event_listener(&input, "focusout", move |_event: web_sys::MouseEvent, _| { runner_ref.add_event_listener(&input, "focusout", move |_event: web_sys::MouseEvent, _| {
// Delay 10 ms, and focus again. // Delay 10 ms, and focus again.
let func = js_sys::Function::new_no_args(&format!( let func = js_sys::Function::new_no_args(&format!(
"document.getElementById('{}').focus()", "document.getElementById('{AGENT_ID}').focus()"
AGENT_ID
)); ));
window window
.set_timeout_with_callback_and_timeout_and_arguments_0(&func, 10) .set_timeout_with_callback_and_timeout_and_arguments_0(&func, 10)
@ -221,8 +220,8 @@ pub fn move_text_cursor(cursor: Option<egui::Pos2>, canvas_id: &str) -> Option<(
let x = (x - canvas.offset_width() as f32 / 2.0) let x = (x - canvas.offset_width() as f32 / 2.0)
.min(canvas.client_width() as f32 - bounding_rect.width() as f32); .min(canvas.client_width() as f32 - bounding_rect.width() as f32);
style.set_property("position", "absolute").ok()?; style.set_property("position", "absolute").ok()?;
style.set_property("top", &format!("{}px", y)).ok()?; style.set_property("top", &format!("{y}px")).ok()?;
style.set_property("left", &format!("{}px", x)).ok() style.set_property("left", &format!("{x}px")).ok()
}) })
} else { } else {
style.set_property("position", "absolute").ok()?; style.set_property("position", "absolute").ok()?;

View File

@ -27,7 +27,7 @@ impl WebPainterGlow {
let gl = std::sync::Arc::new(gl); let gl = std::sync::Arc::new(gl);
let painter = egui_glow::Painter::new(gl, shader_prefix, None) let painter = egui_glow::Painter::new(gl, shader_prefix, None)
.map_err(|error| format!("Error starting glow painter: {}", error))?; .map_err(|err| format!("Error starting glow painter: {err}"))?;
Ok(Self { Ok(Self {
canvas, canvas,

View File

@ -87,8 +87,7 @@ impl WebPainterWgpu {
} else { } else {
// Workaround for https://github.com/gfx-rs/wgpu/issues/3710: // Workaround for https://github.com/gfx-rs/wgpu/issues/3710:
// Don't use `create_surface_from_canvas`, but `create_surface` instead! // Don't use `create_surface_from_canvas`, but `create_surface` instead!
let raw_window = let raw_window = EguiWebWindow(egui::util::hash(("egui on wgpu", canvas_id)) as u32);
EguiWebWindow(egui::util::hash(&format!("egui on wgpu {canvas_id}")) as u32);
canvas.set_attribute("data-raw-handle", &raw_window.0.to_string()); canvas.set_attribute("data-raw-handle", &raw_window.0.to_string());
#[allow(unsafe_code)] #[allow(unsafe_code)]

View File

@ -8,7 +8,7 @@ authors = [
"Emil Ernerfeldt <emil.ernerfeldt@gmail.com>", "Emil Ernerfeldt <emil.ernerfeldt@gmail.com>",
] ]
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/egui-wgpu" homepage = "https://github.com/emilk/egui/tree/master/crates/egui-wgpu"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -560,7 +560,7 @@ impl Renderer {
} else { } else {
// allocate a new texture // allocate a new texture
// Use same label for all resources associated with this texture id (no point in retyping the type) // Use same label for all resources associated with this texture id (no point in retyping the type)
let label_str = format!("egui_texid_{:?}", id); let label_str = format!("egui_texid_{id:?}");
let label = Some(label_str.as_str()); let label = Some(label_str.as_str());
let texture = device.create_texture(&wgpu::TextureDescriptor { let texture = device.create_texture(&wgpu::TextureDescriptor {
label, label,
@ -904,8 +904,7 @@ fn create_sampler(
}; };
device.create_sampler(&wgpu::SamplerDescriptor { device.create_sampler(&wgpu::SamplerDescriptor {
label: Some(&format!( label: Some(&format!(
"egui sampler (mag: {:?}, min {:?})", "egui sampler (mag: {mag_filter:?}, min {min_filter:?})"
mag_filter, min_filter
)), )),
mag_filter, mag_filter,
min_filter, min_filter,

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Bindings for using egui with winit" description = "Bindings for using egui with winit"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/egui-winit" homepage = "https://github.com/emilk/egui/tree/master/crates/egui-winit"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "An easy-to-use immediate mode GUI that runs on both web and native" description = "An easy-to-use immediate mode GUI that runs on both web and native"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "../../README.md" readme = "../../README.md"

View File

@ -566,7 +566,7 @@ impl Context {
} }
let show_error = |widget_rect: Rect, text: String| { 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 color = self.style().visuals.error_fg_color;
let painter = self.debug_painter(); let painter = self.debug_painter();
painter.rect_stroke(widget_rect, 0.0, (1.0, color)); painter.rect_stroke(widget_rect, 0.0, (1.0, color));
@ -612,10 +612,10 @@ impl Context {
let id_str = id.short_debug_format(); let id_str = id.short_debug_format();
if prev_rect.min.distance(new_rect.min) < 4.0 { 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 { } else {
show_error(prev_rect, format!("First 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 {} ID {}", what, id_str)); show_error(new_rect, format!("Second use of {what} ID {id_str}"));
} }
} }
@ -1574,14 +1574,14 @@ impl Context {
let pointer_pos = self let pointer_pos = self
.pointer_hover_pos() .pointer_hover_pos()
.map_or_else(String::new, |pos| format!("{:?}", pos)); .map_or_else(String::new, |pos| format!("{pos:?}"));
ui.label(format!("Pointer pos: {}", pointer_pos)); ui.label(format!("Pointer pos: {pointer_pos}"));
let top_layer = self let top_layer = self
.pointer_hover_pos() .pointer_hover_pos()
.and_then(|pos| self.layer_id_at(pos)) .and_then(|pos| self.layer_id_at(pos))
.map_or_else(String::new, |layer| layer.short_debug_format()); .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); ui.add_space(16.0);
@ -1667,7 +1667,7 @@ impl Context {
ui.image(texture_id, size); 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!("{:.3} MB", meta.bytes_used() as f64 * 1e-6));
ui.label(format!("{:?}", meta.name)); ui.label(format!("{:?}", meta.name));
ui.end_row(); ui.end_row();
@ -1688,8 +1688,7 @@ impl Context {
let (num_state, num_serialized) = self.data(|d| (d.len(), d.count_serialized())); let (num_state, num_serialized) = self.data(|d| (d.len(), d.count_serialized()));
ui.label(format!( ui.label(format!(
"{} widget states stored (of which {} are serialized).", "{num_state} widget states stored (of which {num_serialized} are serialized)."
num_state, num_serialized
)); ));
ui.horizontal(|ui| { ui.horizontal(|ui| {

View File

@ -937,25 +937,25 @@ impl RawInput {
focused, focused,
} = self; } = self;
ui.label(format!("screen_rect: {:?} points", screen_rect)); ui.label(format!("screen_rect: {screen_rect:?} points"));
ui.label(format!("pixels_per_point: {:?}", pixels_per_point)) ui.label(format!("pixels_per_point: {pixels_per_point:?}"))
.on_hover_text( .on_hover_text(
"Also called HDPI factor.\nNumber of physical pixels per each logical pixel.", "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 { if let Some(time) = time {
ui.label(format!("time: {:.3} s", time)); ui.label(format!("time: {time:.3} s"));
} else { } else {
ui.label("time: None"); ui.label("time: None");
} }
ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt)); 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!("hovered_files: {}", hovered_files.len()));
ui.label(format!("dropped_files: {}", dropped_files.len())); ui.label(format!("dropped_files: {}", dropped_files.len()));
ui.label(format!("focused: {}", focused)); ui.label(format!("focused: {focused}"));
ui.scope(|ui| { ui.scope(|ui| {
ui.set_min_height(150.0); ui.set_min_height(150.0);
ui.label(format!("events: {:#?}", events)) ui.label(format!("events: {events:#?}"))
.on_hover_text("key presses etc"); .on_hover_text("key presses etc");
}); });
} }

View File

@ -100,7 +100,7 @@ impl PlatformOutput {
/// This can be used by a text-to-speech system to describe the events (if any). /// This can be used by a text-to-speech system to describe the events (if any).
pub fn events_description(&self) -> String { pub fn events_description(&self) -> String {
// only describe last event: // only describe last event:
if let Some(event) = self.events.iter().rev().next() { if let Some(event) = self.events.iter().next_back() {
match event { match event {
OutputEvent::Clicked(widget_info) OutputEvent::Clicked(widget_info)
| OutputEvent::DoubleClicked(widget_info) | OutputEvent::DoubleClicked(widget_info)
@ -417,12 +417,12 @@ impl OutputEvent {
impl std::fmt::Debug for OutputEvent { impl std::fmt::Debug for OutputEvent {
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
match self { match self {
Self::Clicked(wi) => write!(f, "Clicked({:?})", wi), Self::Clicked(wi) => write!(f, "Clicked({wi:?})"),
Self::DoubleClicked(wi) => write!(f, "DoubleClicked({:?})", wi), Self::DoubleClicked(wi) => write!(f, "DoubleClicked({wi:?})"),
Self::TripleClicked(wi) => write!(f, "TripleClicked({:?})", wi), Self::TripleClicked(wi) => write!(f, "TripleClicked({wi:?})"),
Self::FocusGained(wi) => write!(f, "FocusGained({:?})", wi), Self::FocusGained(wi) => write!(f, "FocusGained({wi:?})"),
Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({:?})", wi), Self::TextSelectionChanged(wi) => write!(f, "TextSelectionChanged({wi:?})"),
Self::ValueChanged(wi) => write!(f, "ValueChanged({:?})", wi), Self::ValueChanged(wi) => write!(f, "ValueChanged({wi:?})"),
} }
} }
} }
@ -609,14 +609,14 @@ impl WidgetInfo {
if let Some(selected) = selected { if let Some(selected) = selected {
if *typ == WidgetType::Checkbox { if *typ == WidgetType::Checkbox {
let state = if *selected { "checked" } else { "unchecked" }; let state = if *selected { "checked" } else { "unchecked" };
description = format!("{} {}", state, description); description = format!("{state} {description}");
} else { } else {
description += if *selected { "selected" } else { "" }; description += if *selected { "selected" } else { "" };
}; };
} }
if let Some(label) = label { if let Some(label) = label {
description = format!("{}: {}", label, description); description = format!("{label}: {description}");
} }
if typ == &WidgetType::TextEdit { if typ == &WidgetType::TextEdit {
@ -630,7 +630,7 @@ impl WidgetInfo {
} else { } else {
text = "blank".into(); text = "blank".into();
} }
description = format!("{}: {}", text, description); description = format!("{text}: {description}");
} }
if let Some(value) = value { if let Some(value) = value {

View File

@ -990,30 +990,28 @@ impl InputState {
}); });
} }
ui.label(format!("scroll_delta: {:?} points", scroll_delta)); ui.label(format!("scroll_delta: {scroll_delta:?} points"));
ui.label(format!("zoom_factor_delta: {:4.2}x", zoom_factor_delta)); ui.label(format!("zoom_factor_delta: {zoom_factor_delta:4.2}x"));
ui.label(format!("screen_rect: {:?} points", screen_rect)); ui.label(format!("screen_rect: {screen_rect:?} points"));
ui.label(format!( ui.label(format!(
"{} physical pixels for each logical point", "{pixels_per_point} physical pixels for each logical point"
pixels_per_point
)); ));
ui.label(format!( ui.label(format!(
"max texture size (on each side): {}", "max texture size (on each side): {max_texture_side}"
max_texture_side
)); ));
ui.label(format!("time: {:.3} s", time)); ui.label(format!("time: {time:.3} s"));
ui.label(format!( ui.label(format!(
"time since previous frame: {:.1} ms", "time since previous frame: {:.1} ms",
1e3 * unstable_dt 1e3 * unstable_dt
)); ));
ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt)); ui.label(format!("predicted_dt: {:.1} ms", 1e3 * predicted_dt));
ui.label(format!("stable_dt: {:.1} ms", 1e3 * stable_dt)); ui.label(format!("stable_dt: {:.1} ms", 1e3 * stable_dt));
ui.label(format!("focused: {}", focused)); ui.label(format!("focused: {focused}"));
ui.label(format!("modifiers: {:#?}", modifiers)); ui.label(format!("modifiers: {modifiers:#?}"));
ui.label(format!("keys_down: {:?}", keys_down)); ui.label(format!("keys_down: {keys_down:?}"));
ui.scope(|ui| { ui.scope(|ui| {
ui.set_min_height(150.0); ui.set_min_height(150.0);
ui.label(format!("events: {:#?}", events)) ui.label(format!("events: {events:#?}"))
.on_hover_text("key presses etc"); .on_hover_text("key presses etc");
}); });
} }
@ -1037,22 +1035,21 @@ impl PointerState {
pointer_events, pointer_events,
} = self; } = self;
ui.label(format!("latest_pos: {:?}", latest_pos)); ui.label(format!("latest_pos: {latest_pos:?}"));
ui.label(format!("interact_pos: {:?}", interact_pos)); ui.label(format!("interact_pos: {interact_pos:?}"));
ui.label(format!("delta: {:?}", delta)); ui.label(format!("delta: {delta:?}"));
ui.label(format!( ui.label(format!(
"velocity: [{:3.0} {:3.0}] points/sec", "velocity: [{:3.0} {:3.0}] points/sec",
velocity.x, velocity.y velocity.x, velocity.y
)); ));
ui.label(format!("down: {:#?}", down)); ui.label(format!("down: {down:#?}"));
ui.label(format!("press_origin: {:?}", press_origin)); ui.label(format!("press_origin: {press_origin:?}"));
ui.label(format!("press_start_time: {:?} s", press_start_time)); ui.label(format!("press_start_time: {press_start_time:?} s"));
ui.label(format!( 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_click_time: {last_click_time:#?}"));
ui.label(format!("last_last_click_time: {:#?}", last_last_click_time)); ui.label(format!("last_last_click_time: {last_last_click_time:#?}"));
ui.label(format!("pointer_events: {:?}", pointer_events)); ui.label(format!("pointer_events: {pointer_events:?}"));
} }
} }

View File

@ -286,7 +286,7 @@ impl TouchState {
impl TouchState { impl TouchState {
pub fn ui(&self, ui: &mut crate::Ui) { 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)]`: // This outputs less clutter than `#[derive(Debug)]`:
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
for (id, touch) in &self.active_touches { 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))?; f.write_fmt(format_args!("gesture: {:#?}\n", self.gesture_state))?;
Ok(()) Ok(())

View File

@ -31,10 +31,7 @@ pub(crate) fn font_texture_ui(ui: &mut Ui, [width, height]: [usize; 2]) -> Respo
Color32::BLACK Color32::BLACK
}; };
ui.label(format!( ui.label(format!("Texture size: {width} x {height} (hover to zoom)"));
"Texture size: {} x {} (hover to zoom)",
width, height
));
if width <= 1 || height <= 1 { if width <= 1 || height <= 1 {
return; return;
} }
@ -108,7 +105,7 @@ impl Widget for &epaint::stats::PaintStats {
label(ui, shape_path, "paths"); label(ui, shape_path, "paths");
label(ui, shape_mesh, "nested meshes"); label(ui, shape_mesh, "nested meshes");
label(ui, shape_vec, "nested shapes"); 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.add_space(10.0);
ui.label("Text shapes:"); ui.label("Text shapes:");

View File

@ -226,7 +226,7 @@ impl Painter {
pub fn error(&self, pos: Pos2, text: impl std::fmt::Display) -> Rect { pub fn error(&self, pos: Pos2, text: impl std::fmt::Display) -> Rect {
let color = self.ctx.style().visuals.error_fg_color; 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 /// text with a background

View File

@ -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 ui.button("📋").on_hover_text("Click to copy").clicked() {
if alpha == Alpha::Opaque { 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 { } 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 { if alpha == Alpha::Opaque {
ui.label(format!("rgb({}, {}, {})", r, g, b)) ui.label(format!("rgb({r}, {g}, {b})"))
.on_hover_text("Red Green Blue"); .on_hover_text("Red Green Blue");
} else { } 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"); .on_hover_text("Red Green Blue with premultiplied Alpha");
} }
}); });

View File

@ -627,7 +627,7 @@ impl<'a> Widget for DragValue<'a> {
// The value is exposed as a string by the text edit widget // The value is exposed as a string by the text edit widget
// when in edit mode. // when in edit mode.
if !is_kb_editing { 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); builder.set_value(value_text);
} }
}); });

View File

@ -1732,7 +1732,7 @@ pub(super) fn rulers_at_value(
let mut prefix = String::new(); let mut prefix = String::new();
if !name.is_empty() { if !name.is_empty() {
prefix = format!("{}\n", name); prefix = format!("{name}\n");
} }
let text = { let text = {

View File

@ -125,8 +125,8 @@ impl ToString for LineStyle {
fn to_string(&self) -> String { fn to_string(&self) -> String {
match self { match self {
LineStyle::Solid => "Solid".into(), LineStyle::Solid => "Solid".into(),
LineStyle::Dotted { spacing } => format!("Dotted{}Px", spacing), LineStyle::Dotted { spacing } => format!("Dotted{spacing}Px"),
LineStyle::Dashed { length } => format!("Dashed{}Px", length), LineStyle::Dashed { length } => format!("Dashed{length}Px"),
} }
} }
} }

View File

@ -1453,7 +1453,7 @@ impl PreparedPlot {
let axis_range = match axis { let axis_range = match axis {
0 => bounds.range_x(), 0 => bounds.range_x(),
1 => bounds.range_y(), 1 => bounds.range_y(),
_ => panic!("Axis {} does not exist.", axis), _ => panic!("Axis {axis} does not exist."),
}; };
let font_id = TextStyle::Body.resolve(ui.style()); 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; let is_integral = number as i64 as f64 == number;
if is_integral { if is_integral {
// perfect integer - show it as such: // perfect integer - show it as such:
format!("{:.0}", number) format!("{number:.0}")
} else { } else {
// make sure we tell the user it is not an integer by always showing a decimal or two: // 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) format!("{:.*}", num_decimals.at_least(1), number)

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false
default-run = "egui_demo_app" default-run = "egui_demo_app"

View File

@ -133,7 +133,7 @@ fn ui_url(ui: &mut egui::Ui, frame: &mut eframe::Frame, url: &mut String) -> boo
if ui.button("Random image").clicked() { if ui.button("Random image").clicked() {
let seed = ui.input(|i| i.time); let seed = ui.input(|i| i.time);
let side = 640; let side = 640;
*url = format!("https://picsum.photos/seed/{}/{}", seed, side); *url = format!("https://picsum.photos/seed/{seed}/{side}");
trigger_fetch = true; trigger_fetch = true;
} }
}); });

View File

@ -232,8 +232,7 @@ impl BackendPanel {
if ui if ui
.add_enabled(enabled, egui::Button::new("Reset")) .add_enabled(enabled, egui::Button::new("Reset"))
.on_hover_text(format!( .on_hover_text(format!(
"Reset scale to native value ({:.1})", "Reset scale to native value ({native_pixels_per_point:.1})"
native_pixels_per_point
)) ))
.clicked() .clicked()
{ {
@ -441,7 +440,7 @@ impl EguiWindows {
.stick_to_bottom(true) .stick_to_bottom(true)
.show(ui, |ui| { .show(ui, |ui| {
for event in output_event_history { for event in output_event_history {
ui.label(format!("{:?}", event)); ui.label(format!("{event:?}"));
} }
}); });
}); });

View File

@ -354,7 +354,7 @@ impl WrapApp {
{ {
selected_anchor = anchor; selected_anchor = anchor;
if frame.is_web() { if frame.is_web() {
ui.output_mut(|o| o.open_url(format!("#{}", anchor))); ui.output_mut(|o| o.open_url(format!("#{anchor}")));
} }
} }
} }

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Example library for egui" description = "Example library for egui"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_demo_lib" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_demo_lib"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -83,11 +83,11 @@ fn about_immediate_mode(ui: &mut egui::Ui) {
fn links(ui: &mut egui::Ui) { fn links(ui: &mut egui::Ui) {
use egui::special_emojis::{GITHUB, TWITTER}; use egui::special_emojis::{GITHUB, TWITTER};
ui.hyperlink_to( ui.hyperlink_to(
format!("{} egui on GitHub", GITHUB), format!("{GITHUB} egui on GitHub"),
"https://github.com/emilk/egui", "https://github.com/emilk/egui",
); );
ui.hyperlink_to( ui.hyperlink_to(
format!("{} @ernerfeldt", TWITTER), format!("{TWITTER} @ernerfeldt"),
"https://twitter.com/ernerfeldt", "https://twitter.com/ernerfeldt",
); );
ui.hyperlink_to("egui documentation", "https://docs.rs/egui/"); ui.hyperlink_to("egui documentation", "https://docs.rs/egui/");

View File

@ -121,7 +121,7 @@ impl CodeExample {
ui.separator(); ui.separator();
code_view_ui(ui, &format!("{:#?}", self)); code_view_ui(ui, &format!("{self:#?}"));
ui.separator(); ui.separator();

View File

@ -251,11 +251,11 @@ impl DemoWindows {
use egui::special_emojis::{GITHUB, TWITTER}; use egui::special_emojis::{GITHUB, TWITTER};
ui.hyperlink_to( ui.hyperlink_to(
format!("{} egui on GitHub", GITHUB), format!("{GITHUB} egui on GitHub"),
"https://github.com/emilk/egui", "https://github.com/emilk/egui",
); );
ui.hyperlink_to( ui.hyperlink_to(
format!("{} @ernerfeldt", TWITTER), format!("{TWITTER} @ernerfeldt"),
"https://twitter.com/ernerfeldt", "https://twitter.com/ernerfeldt",
); );

View File

@ -140,7 +140,7 @@ impl LayoutTest {
Direction::TopDown, Direction::TopDown,
Direction::BottomUp, Direction::BottomUp,
] { ] {
ui.radio_value(&mut self.layout.main_dir, dir, format!("{:?}", dir)); ui.radio_value(&mut self.layout.main_dir, dir, format!("{dir:?}"));
} }
}); });
@ -162,7 +162,7 @@ impl LayoutTest {
ui.horizontal(|ui| { ui.horizontal(|ui| {
ui.label("Cross Align:"); ui.label("Cross Align:");
for &align in &[Align::Min, Align::Center, Align::Max] { for &align in &[Align::Min, Align::Center, Align::Max] {
ui.radio_value(&mut self.layout.cross_align, align, format!("{:?}", align)); ui.radio_value(&mut self.layout.cross_align, align, format!("{align:?}"));
} }
}); });

View File

@ -455,7 +455,7 @@ impl Tree {
.into_iter() .into_iter()
.enumerate() .enumerate()
.filter_map(|(i, mut tree)| { .filter_map(|(i, mut tree)| {
if tree.ui_impl(ui, depth + 1, &format!("child #{}", i)) == Action::Keep { if tree.ui_impl(ui, depth + 1, &format!("child #{i}")) == Action::Keep {
Some(tree) Some(tree)
} else { } else {
None None

View File

@ -50,7 +50,7 @@ impl super::View for MultiTouch {
ui.label("Try touch gestures Pinch/Stretch, Rotation, and Pressure with 2+ fingers."); ui.label("Try touch gestures Pinch/Stretch, Rotation, and Pressure with 2+ fingers.");
let num_touches = ui.input(|i| i.multi_touch().map_or(0, |mt| mt.num_touches)); let num_touches = ui.input(|i| i.multi_touch().map_or(0, |mt| mt.num_touches));
ui.label(format!("Current touches: {}", num_touches)); ui.label(format!("Current touches: {num_touches}"));
let color = if ui.visuals().dark_mode { let color = if ui.visuals().dark_mode {
Color32::WHITE Color32::WHITE

View File

@ -326,7 +326,7 @@ impl MarkerDemo {
[5.0, 0.0 + y_offset], [5.0, 0.0 + y_offset],
[6.0, 0.5 + y_offset], [6.0, 0.5 + y_offset],
]) ])
.name(format!("{:?}", marker)) .name(format!("{marker:?}"))
.filled(self.fill_markers) .filled(self.fill_markers)
.radius(self.marker_radius) .radius(self.marker_radius)
.shape(marker); .shape(marker);
@ -416,7 +416,7 @@ impl LegendDemo {
ui.label("Position:"); ui.label("Position:");
ui.horizontal(|ui| { ui.horizontal(|ui| {
Corner::all().for_each(|position| { Corner::all().for_each(|position| {
ui.selectable_value(&mut config.position, position, format!("{:?}", position)); ui.selectable_value(&mut config.position, position, format!("{position:?}"));
}); });
}); });
ui.end_row(); ui.end_row();
@ -774,21 +774,18 @@ impl InteractionDemo {
"origin in screen coordinates: x: {:.02}, y: {:.02}", "origin in screen coordinates: x: {:.02}, y: {:.02}",
screen_pos.x, screen_pos.y screen_pos.x, screen_pos.y
)); ));
ui.label(format!("plot hovered: {}", hovered)); ui.label(format!("plot hovered: {hovered}"));
let coordinate_text = if let Some(coordinate) = pointer_coordinate { let coordinate_text = if let Some(coordinate) = pointer_coordinate {
format!("x: {:.02}, y: {:.02}", coordinate.x, coordinate.y) format!("x: {:.02}, y: {:.02}", coordinate.x, coordinate.y)
} else { } else {
"None".to_owned() "None".to_owned()
}; };
ui.label(format!("pointer coordinate: {}", coordinate_text)); ui.label(format!("pointer coordinate: {coordinate_text}"));
let coordinate_text = format!( let coordinate_text = format!(
"x: {:.02}, y: {:.02}", "x: {:.02}, y: {:.02}",
pointer_coordinate_drag_delta.x, pointer_coordinate_drag_delta.y pointer_coordinate_drag_delta.x, pointer_coordinate_drag_delta.y
); );
ui.label(format!( ui.label(format!("pointer coordinate drag delta: {coordinate_text}"));
"pointer coordinate drag delta: {}",
coordinate_text
));
response response
} }

View File

@ -232,10 +232,10 @@ impl super::View for ScrollTo {
for item in 1..=50 { for item in 1..=50 {
if track_item && item == self.track_item { if track_item && item == self.track_item {
let response = let response =
ui.colored_label(Color32::YELLOW, format!("This is item {}", item)); ui.colored_label(Color32::YELLOW, format!("This is item {item}"));
response.scroll_to_me(self.tack_item_align); response.scroll_to_me(self.tack_item_align);
} else { } else {
ui.label(format!("This is item {}", item)); ui.label(format!("This is item {item}"));
} }
} }
}); });
@ -254,8 +254,7 @@ impl super::View for ScrollTo {
ui.separator(); ui.separator();
ui.label(format!( ui.label(format!(
"Scroll offset: {:.0}/{:.0} px", "Scroll offset: {current_scroll:.0}/{max_scroll:.0} px"
current_scroll, max_scroll
)); ));
ui.separator(); ui.separator();

View File

@ -20,7 +20,7 @@ impl super::View for CursorTest {
ui.heading("Hover to switch cursor icon:"); ui.heading("Hover to switch cursor icon:");
for &cursor_icon in &egui::CursorIcon::ALL { for &cursor_icon in &egui::CursorIcon::ALL {
let _ = ui let _ = ui
.button(format!("{:?}", cursor_icon)) .button(format!("{cursor_icon:?}"))
.on_hover_cursor(cursor_icon); .on_hover_cursor(cursor_icon);
} }
ui.add(crate::egui_github_link_file!()); ui.add(crate::egui_github_link_file!());
@ -239,7 +239,7 @@ impl super::View for TableTest {
for row in 0..self.num_rows { for row in 0..self.num_rows {
for col in 0..self.num_cols { for col in 0..self.num_cols {
if col == 0 { if col == 0 {
ui.label(format!("row {}", row)); ui.label(format!("row {row}"));
} else { } else {
let word_idx = row * 3 + col * 5; let word_idx = row * 3 + col * 5;
let word_count = (row * 5 + col * 75) % 13; let word_count = (row * 5 + col * 75) % 13;
@ -350,13 +350,13 @@ impl super::View for InputTest {
use std::fmt::Write as _; use std::fmt::Write as _;
if response.clicked_by(button) { if response.clicked_by(button) {
writeln!(new_info, "Clicked by {:?} button", button).ok(); writeln!(new_info, "Clicked by {button:?} button").ok();
} }
if response.double_clicked_by(button) { if response.double_clicked_by(button) {
writeln!(new_info, "Double-clicked by {:?} button", button).ok(); writeln!(new_info, "Double-clicked by {button:?} button").ok();
} }
if response.triple_clicked_by(button) { if response.triple_clicked_by(button) {
writeln!(new_info, "Triple-clicked by {:?} button", button).ok(); writeln!(new_info, "Triple-clicked by {button:?} button").ok();
} }
if response.dragged_by(button) { if response.dragged_by(button) {
writeln!( writeln!(

View File

@ -126,7 +126,7 @@ impl WidgetGallery {
ui.add(doc_link_label("Hyperlink", "Hyperlink")); ui.add(doc_link_label("Hyperlink", "Hyperlink"));
use egui::special_emojis::GITHUB; use egui::special_emojis::GITHUB;
ui.hyperlink_to( ui.hyperlink_to(
format!("{} egui on GitHub", GITHUB), format!("{GITHUB} egui on GitHub"),
"https://github.com/emilk/egui", "https://github.com/emilk/egui",
); );
ui.end_row(); ui.end_row();
@ -173,7 +173,7 @@ impl WidgetGallery {
ui.add(doc_link_label("ComboBox", "ComboBox")); ui.add(doc_link_label("ComboBox", "ComboBox"));
egui::ComboBox::from_label("Take your pick") egui::ComboBox::from_label("Take your pick")
.selected_text(format!("{:?}", radio)) .selected_text(format!("{radio:?}"))
.show_ui(ui, |ui| { .show_ui(ui, |ui| {
ui.style_mut().wrap = Some(false); ui.style_mut().wrap = Some(false);
ui.set_min_width(60.0); ui.set_min_width(60.0);
@ -277,8 +277,8 @@ fn example_plot(ui: &mut egui::Ui) -> egui::Response {
} }
fn doc_link_label<'a>(title: &'a str, search_term: &'a str) -> impl egui::Widget + 'a { fn doc_link_label<'a>(title: &'a str, search_term: &'a str) -> impl egui::Widget + 'a {
let label = format!("{}:", title); let label = format!("{title}:");
let url = format!("https://docs.rs/egui?search={}", search_term); let url = format!("https://docs.rs/egui?search={search_term}");
move |ui: &mut egui::Ui| { move |ui: &mut egui::Ui| {
ui.hyperlink_to(label, url).on_hover_ui(|ui| { ui.hyperlink_to(label, url).on_hover_ui(|ui| {
ui.horizontal_wrapped(|ui| { ui.horizontal_wrapped(|ui| {

View File

@ -161,7 +161,7 @@ fn numbered_point(ui: &mut Ui, width: f32, number: &str) -> Response {
let font_id = TextStyle::Body.resolve(ui.style()); let font_id = TextStyle::Body.resolve(ui.style());
let row_height = ui.fonts(|f| f.row_height(&font_id)); let row_height = ui.fonts(|f| f.row_height(&font_id));
let (rect, response) = ui.allocate_exact_size(vec2(width, row_height), Sense::hover()); let (rect, response) = ui.allocate_exact_size(vec2(width, row_height), Sense::hover());
let text = format!("{}.", number); let text = format!("{number}.");
let text_color = ui.visuals().strong_text_color(); let text_color = ui.visuals().strong_text_color();
ui.painter().text( ui.painter().text(
rect.right_center(), rect.right_center(),

View File

@ -8,7 +8,7 @@ authors = [
] ]
description = "Extra functionality and widgets for the egui GUI library" description = "Extra functionality and widgets for the egui GUI library"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui" homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -428,6 +428,6 @@ fn month_name(i: u32) -> &'static str {
10 => "October", 10 => "October",
11 => "November", 11 => "November",
12 => "December", 12 => "December",
_ => panic!("Unknown month: {}", i), _ => panic!("Unknown month: {i}"),
} }
} }

View File

@ -258,7 +258,7 @@ pub fn load_svg_bytes_with_size(
}; };
let mut pixmap = tiny_skia::Pixmap::new(w, h) let mut pixmap = tiny_skia::Pixmap::new(w, h)
.ok_or_else(|| format!("Failed to create SVG Pixmap of size {}x{}", w, h))?; .ok_or_else(|| format!("Failed to create SVG Pixmap of size {w}x{h}"))?;
resvg::render(&rtree, fit_to, Default::default(), pixmap.as_mut()) resvg::render(&rtree, fit_to, Default::default(), pixmap.as_mut())
.ok_or_else(|| "Failed to render SVG".to_owned())?; .ok_or_else(|| "Failed to render SVG".to_owned())?;

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Bindings for using egui natively using the glium library" description = "Bindings for using egui natively using the glium library"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glium" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glium"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Bindings for using egui natively using the glow library" description = "Bindings for using egui natively using the glow library"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glow" homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glow"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Minimal 2D math library for GUI work" description = "Minimal 2D math library for GUI work"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/emath" homepage = "https://github.com/emilk/egui/tree/master/crates/emath"
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
readme = "README.md" readme = "README.md"

View File

@ -183,9 +183,7 @@ where
/// Round a value to the given number of decimal places. /// Round a value to the given number of decimal places.
pub fn round_to_decimals(value: f64, decimal_places: usize) -> f64 { pub fn round_to_decimals(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!("{value:.decimal_places$}").parse().unwrap_or(value)
.parse()
.unwrap_or(value)
} }
pub fn format_with_minimum_decimals(value: f64, decimals: usize) -> String { pub fn format_with_minimum_decimals(value: f64, decimals: usize) -> String {
@ -203,7 +201,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
if min_decimals != max_decimals { if min_decimals != max_decimals {
// Ugly/slow way of doing this. TODO(emilk): clean up precision. // Ugly/slow way of doing this. TODO(emilk): clean up precision.
for decimals in min_decimals..max_decimals { for decimals in min_decimals..max_decimals {
let text = format!("{:.*}", decimals, value); let text = format!("{value:.decimals$}");
let epsilon = 16.0 * f32::EPSILON; // margin large enough to handle most peoples round-tripping needs let epsilon = 16.0 * f32::EPSILON; // margin large enough to handle most peoples round-tripping needs
if almost_equal(text.parse::<f32>().unwrap(), value as f32, epsilon) { if almost_equal(text.parse::<f32>().unwrap(), value as f32, epsilon) {
// Enough precision to show the value accurately - good! // Enough precision to show the value accurately - good!
@ -214,7 +212,7 @@ pub fn format_with_decimals_in_range(value: f64, decimal_range: RangeInclusive<u
// Probably the value was set not by the slider, but from outside. // Probably the value was set not by the slider, but from outside.
// In any case: show the full value // In any case: show the full value
} }
format!("{:.*}", max_decimals, value) format!("{value:.max_decimals$}")
} }
/// Return true when arguments are the same within some rounding error. /// Return true when arguments are the same within some rounding error.

View File

@ -206,7 +206,7 @@ impl std::ops::Index<usize> for Pos2 {
match index { match index {
0 => &self.x, 0 => &self.x,
1 => &self.y, 1 => &self.y,
_ => panic!("Pos2 index out of bounds: {}", index), _ => panic!("Pos2 index out of bounds: {index}"),
} }
} }
} }
@ -217,7 +217,7 @@ impl std::ops::IndexMut<usize> for Pos2 {
match index { match index {
0 => &mut self.x, 0 => &mut self.x,
1 => &mut self.y, 1 => &mut self.y,
_ => panic!("Pos2 index out of bounds: {}", index), _ => panic!("Pos2 index out of bounds: {index}"),
} }
} }
} }

View File

@ -184,10 +184,7 @@ mod test {
let expected = vec2(0.0, 3.0); let expected = vec2(0.0, 3.0);
assert!( assert!(
(rotated - expected).length() < 1e-5, (rotated - expected).length() < 1e-5,
"Expected {:?} to equal {:?}. rot: {:?}", "Expected {rotated:?} to equal {expected:?}. rot: {rot:?}",
rotated,
expected,
rot,
); );
let undone = rot.inverse() * rot; let undone = rot.inverse() * rot;

View File

@ -292,7 +292,7 @@ impl std::ops::Index<usize> for Vec2 {
match index { match index {
0 => &self.x, 0 => &self.x,
1 => &self.y, 1 => &self.y,
_ => panic!("Vec2 index out of bounds: {}", index), _ => panic!("Vec2 index out of bounds: {index}"),
} }
} }
} }
@ -303,7 +303,7 @@ impl std::ops::IndexMut<usize> for Vec2 {
match index { match index {
0 => &mut self.x, 0 => &mut self.x,
1 => &mut self.y, 1 => &mut self.y,
_ => panic!("Vec2 index out of bounds: {}", index), _ => panic!("Vec2 index out of bounds: {index}"),
} }
} }
} }

View File

@ -4,7 +4,7 @@ version = "0.22.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "Minimal 2D graphics library for GUI work" description = "Minimal 2D graphics library for GUI work"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
homepage = "https://github.com/emilk/egui/tree/master/crates/epaint" homepage = "https://github.com/emilk/egui/tree/master/crates/epaint"
license = "(MIT OR Apache-2.0) AND OFL-1.1 AND LicenseRef-UFL-1.0" # OFL and UFL used by default_fonts. See https://github.com/emilk/egui/issues/2321 license = "(MIT OR Apache-2.0) AND OFL-1.1 AND LicenseRef-UFL-1.0" # OFL and UFL used by default_fonts. See https://github.com/emilk/egui/issues/2321
readme = "README.md" readme = "README.md"

View File

@ -251,8 +251,7 @@ impl Mesh {
assert!( assert!(
index_cursor > span_start, index_cursor > span_start,
"One triangle spanned more than {} vertices", "One triangle spanned more than {MAX_SIZE} vertices"
MAX_SIZE
); );
let mesh = Mesh16 { let mesh = Mesh16 {

View File

@ -333,7 +333,7 @@ mod rw_lock_impl {
fn format_backtrace(backtrace: &mut backtrace::Backtrace) -> String { fn format_backtrace(backtrace: &mut backtrace::Backtrace) -> String {
backtrace.resolve(); backtrace.resolve();
let stacktrace = format!("{:?}", backtrace); let stacktrace = format!("{backtrace:?}");
// Remove irrelevant parts of the stacktrace: // Remove irrelevant parts of the stacktrace:
let end_offset = stacktrace let end_offset = stacktrace

View File

@ -106,7 +106,7 @@ impl AllocInfo {
element_size: ElementSize::Homogeneous(element_size), element_size: ElementSize::Homogeneous(element_size),
num_allocs: 1, num_allocs: 1,
num_elements: slice.len(), num_elements: slice.len(),
num_bytes: slice.len() * element_size, num_bytes: std::mem::size_of_val(slice),
} }
} }

View File

@ -367,8 +367,7 @@ impl Font {
.or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR)) .or_else(|| slf.glyph_info_no_cache_or_fallback(FALLBACK_REPLACEMENT_CHAR))
.unwrap_or_else(|| { .unwrap_or_else(|| {
panic!( panic!(
"Failed to find replacement characters {:?} or {:?}", "Failed to find replacement characters {PRIMARY_REPLACEMENT_CHAR:?} or {FALLBACK_REPLACEMENT_CHAR:?}"
PRIMARY_REPLACEMENT_CHAR, FALLBACK_REPLACEMENT_CHAR
) )
}); });
slf.replacement_glyph = replacement_glyph; slf.replacement_glyph = replacement_glyph;

View File

@ -200,7 +200,7 @@ fn ab_glyph_font_from_font_data(name: &str, data: &FontData) -> ab_glyph::FontAr
.map(ab_glyph::FontArc::from) .map(ab_glyph::FontArc::from)
} }
} }
.unwrap_or_else(|err| panic!("Error parsing {:?} TTF/OTF font file: {}", name, err)) .unwrap_or_else(|err| panic!("Error parsing {name:?} TTF/OTF font file: {err}"))
} }
/// Describes the font data and the sizes to use. /// Describes the font data and the sizes to use.
@ -586,8 +586,7 @@ impl FontsImpl {
) -> Self { ) -> Self {
assert!( assert!(
0.0 < pixels_per_point && pixels_per_point < 100.0, 0.0 < pixels_per_point && pixels_per_point < 100.0,
"pixels_per_point out of range: {}", "pixels_per_point out of range: {pixels_per_point}"
pixels_per_point
); );
let texture_width = max_texture_side.at_most(8 * 1024); let texture_width = max_texture_side.at_most(8 * 1024);
@ -627,9 +626,8 @@ impl FontsImpl {
.entry((HashableF32(*size), family.clone())) .entry((HashableF32(*size), family.clone()))
.or_insert_with(|| { .or_insert_with(|| {
let fonts = &self.definitions.families.get(family); let fonts = &self.definitions.families.get(family);
let fonts = fonts.unwrap_or_else(|| { let fonts = fonts
panic!("FontFamily::{:?} is not bound to any fonts", family) .unwrap_or_else(|| panic!("FontFamily::{family:?} is not bound to any fonts"));
});
let fonts: Vec<Arc<FontImpl>> = fonts let fonts: Vec<Arc<FontImpl>> = fonts
.iter() .iter()
@ -752,17 +750,14 @@ impl FontImplCache {
let (tweak, ab_glyph_font) = self let (tweak, ab_glyph_font) = self
.ab_glyph_fonts .ab_glyph_fonts
.get(font_name) .get(font_name)
.unwrap_or_else(|| panic!("No font data found for {:?}", font_name)) .unwrap_or_else(|| panic!("No font data found for {font_name:?}"))
.clone(); .clone();
let scale_in_pixels = self.pixels_per_point * scale_in_points; let scale_in_pixels = self.pixels_per_point * scale_in_points;
// Scale the font properly (see https://github.com/emilk/egui/issues/2068). // Scale the font properly (see https://github.com/emilk/egui/issues/2068).
let units_per_em = ab_glyph_font.units_per_em().unwrap_or_else(|| { let units_per_em = ab_glyph_font.units_per_em().unwrap_or_else(|| {
panic!( panic!("The font unit size of {font_name:?} exceeds the expected range (16..=16384)")
"The font unit size of {:?} exceeds the expected range (16..=16384)",
font_name
)
}); });
let font_scaling = ab_glyph_font.height_unscaled() / units_per_em; let font_scaling = ab_glyph_font.height_unscaled() / units_per_em;
let scale_in_pixels = scale_in_pixels * font_scaling; let scale_in_pixels = scale_in_pixels * font_scaling;

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -144,7 +144,7 @@ impl RotatingTriangle {
let shader = gl let shader = gl
.create_shader(*shader_type) .create_shader(*shader_type)
.expect("Cannot create shader"); .expect("Cannot create shader");
gl.shader_source(shader, &format!("{}\n{}", shader_version, shader_source)); gl.shader_source(shader, &format!("{shader_version}\n{shader_source}"));
gl.compile_shader(shader); gl.compile_shader(shader);
assert!( assert!(
gl.get_shader_compile_status(shader), gl.get_shader_compile_status(shader),

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["tami5 <kkharji@proton.me>"] authors = ["tami5 <kkharji@proton.me>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -58,8 +58,7 @@ fn parse_response(response: ehttp::Response) -> Result<RetainedImage, String> {
RetainedImage::from_image_bytes(&response.url, &response.bytes) RetainedImage::from_image_bytes(&response.url, &response.bytes)
} else { } else {
Err(format!( Err(format!(
"Expected image, found content-type {:?}", "Expected image, found content-type {content_type:?}"
content_type
)) ))
} }
} }

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Maxim Osipenko <maxim1999max@gmail.com>"] authors = ["Maxim Osipenko <maxim1999max@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -63,7 +63,7 @@ fn new_worker(
) -> (JoinHandle<()>, mpsc::SyncSender<egui::Context>) { ) -> (JoinHandle<()>, mpsc::SyncSender<egui::Context>) {
let (show_tx, show_rc) = mpsc::sync_channel(0); let (show_tx, show_rc) = mpsc::sync_channel(0);
let handle = std::thread::Builder::new() let handle = std::thread::Builder::new()
.name(format!("EguiPanelWorker {}", thread_nr)) .name(format!("EguiPanelWorker {thread_nr}"))
.spawn(move || { .spawn(move || {
let mut state = ThreadState::new(thread_nr); let mut state = ThreadState::new(thread_nr);
while let Ok(ctx) = show_rc.recv() { while let Ok(ctx) = show_rc.recv() {

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Jose Palazon <jose@palako.com>"] authors = ["Jose Palazon <jose@palako.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -62,7 +62,7 @@ fn start_puffin_server() {
std::mem::forget(puffin_server); std::mem::forget(puffin_server);
} }
Err(err) => { Err(err) => {
eprintln!("Failed to start puffin server: {}", err); eprintln!("Failed to start puffin server: {err}");
} }
}; };
} }

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["hacknus <l_stoeckli@bluewin.ch>"] authors = ["hacknus <l_stoeckli@bluewin.ch>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false
[dependencies] [dependencies]

View File

@ -14,7 +14,7 @@ fn main() -> Result<(), eframe::Error> {
eframe::run_native( eframe::run_native(
"My egui App with a plot", "My egui App with a plot",
options, options,
Box::new(|_cc| Box::new(MyApp::default())), Box::new(|_cc| Box::<MyApp>::default()),
) )
} }

View File

@ -7,7 +7,7 @@ authors = [
] ]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"] authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false

View File

@ -4,7 +4,7 @@ version = "0.1.0"
authors = ["TicClick <ya@ticclick.ch>"] authors = ["TicClick <ya@ticclick.ch>"]
license = "MIT OR Apache-2.0" license = "MIT OR Apache-2.0"
edition = "2021" edition = "2021"
rust-version = "1.65" rust-version = "1.67"
publish = false publish = false
[dependencies] [dependencies]

View File

@ -19,7 +19,7 @@ fn main() -> eframe::Result<()> {
} }
fn repr(attention: UserAttentionType) -> String { fn repr(attention: UserAttentionType) -> String {
format!("{:?}", attention) format!("{attention:?}")
} }
struct Application { struct Application {

View File

@ -5,6 +5,6 @@
# to the user in the error, instead of "error: invalid channel name '[toolchain]'". # to the user in the error, instead of "error: invalid channel name '[toolchain]'".
[toolchain] [toolchain]
channel = "1.65.0" channel = "1.67.0"
components = [ "rustfmt", "clippy" ] components = [ "rustfmt", "clippy" ]
targets = [ "wasm32-unknown-unknown" ] targets = [ "wasm32-unknown-unknown" ]

View File

@ -3,7 +3,7 @@
# We cannot forbid all these methods in the main `clippy.toml` because of # We cannot forbid all these methods in the main `clippy.toml` because of
# https://github.com/rust-lang/rust-clippy/issues/10406 # https://github.com/rust-lang/rust-clippy/issues/10406
msrv = "1.65" msrv = "1.67"
# https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods # https://rust-lang.github.io/rust-clippy/master/index.html#disallowed_methods
disallowed-methods = [ disallowed-methods = [