diff --git a/crates/egui/src/util/cache.rs b/crates/egui/src/util/cache.rs index b1c65565..52b3bd57 100644 --- a/crates/egui/src/util/cache.rs +++ b/crates/egui/src/util/cache.rs @@ -126,7 +126,7 @@ impl CacheStorage { pub fn cache(&mut self) -> &mut FrameCache { self.caches .entry(std::any::TypeId::of::()) - .or_insert_with(|| Box::new(FrameCache::default())) + .or_insert_with(|| Box::::default()) .as_any_mut() .downcast_mut::() .unwrap() diff --git a/crates/egui_demo_app/src/apps/custom3d_glow.rs b/crates/egui_demo_app/src/apps/custom3d_glow.rs index 701c4dc1..ff545bb6 100644 --- a/crates/egui_demo_app/src/apps/custom3d_glow.rs +++ b/crates/egui_demo_app/src/apps/custom3d_glow.rs @@ -158,9 +158,11 @@ impl RotatingTriangle { .collect(); gl.link_program(program); - if !gl.get_program_link_status(program) { - panic!("{}", gl.get_program_info_log(program)); - } + assert!( + gl.get_program_link_status(program), + "{}", + gl.get_program_info_log(program) + ); for shader in shaders { gl.detach_shader(program, shader); diff --git a/crates/egui_demo_lib/src/demo/demo_app_windows.rs b/crates/egui_demo_lib/src/demo/demo_app_windows.rs index 31a28ae8..4ad6c2d9 100644 --- a/crates/egui_demo_lib/src/demo/demo_app_windows.rs +++ b/crates/egui_demo_lib/src/demo/demo_app_windows.rs @@ -20,26 +20,26 @@ struct Demos { impl Default for Demos { fn default() -> Self { Self::from_demos(vec![ - Box::new(super::paint_bezier::PaintBezier::default()), - Box::new(super::code_editor::CodeEditor::default()), - Box::new(super::code_example::CodeExample::default()), - Box::new(super::context_menu::ContextMenus::default()), - Box::new(super::dancing_strings::DancingStrings::default()), - Box::new(super::drag_and_drop::DragAndDropDemo::default()), - Box::new(super::font_book::FontBook::default()), - Box::new(super::MiscDemoWindow::default()), - Box::new(super::multi_touch::MultiTouch::default()), - Box::new(super::painting::Painting::default()), - Box::new(super::plot_demo::PlotDemo::default()), - Box::new(super::scrolling::Scrolling::default()), - Box::new(super::sliders::Sliders::default()), - Box::new(super::strip_demo::StripDemo::default()), - Box::new(super::table_demo::TableDemo::default()), - Box::new(super::text_edit::TextEdit::default()), - Box::new(super::widget_gallery::WidgetGallery::default()), - Box::new(super::window_options::WindowOptions::default()), - Box::new(super::tests::WindowResizeTest::default()), - Box::new(super::window_with_panels::WindowWithPanels::default()), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), ]) } } @@ -89,13 +89,13 @@ struct Tests { impl Default for Tests { fn default() -> Self { Self::from_demos(vec![ - Box::new(super::tests::CursorTest::default()), - Box::new(super::highlighting::Highlighting::default()), - Box::new(super::tests::IdTest::default()), - Box::new(super::tests::InputTest::default()), - Box::new(super::layout_test::LayoutTest::default()), - Box::new(super::tests::ManualLayoutTest::default()), - Box::new(super::tests::TableTest::default()), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), + Box::::default(), ]) } } diff --git a/crates/egui_demo_lib/src/demo/table_demo.rs b/crates/egui_demo_lib/src/demo/table_demo.rs index 73541831..8fdea420 100644 --- a/crates/egui_demo_lib/src/demo/table_demo.rs +++ b/crates/egui_demo_lib/src/demo/table_demo.rs @@ -206,7 +206,7 @@ impl TableDemo { } } body.heterogeneous_rows( - (0..self.num_rows).into_iter().map(row_thickness), + (0..self.num_rows).map(row_thickness), |row_index, mut row| { row.col(|ui| { ui.label(row_index.to_string()); diff --git a/crates/emath/src/align.rs b/crates/emath/src/align.rs index 5a09f8ac..9d7ccf81 100644 --- a/crates/emath/src/align.rs +++ b/crates/emath/src/align.rs @@ -3,10 +3,11 @@ use crate::*; /// left/center/right or top/center/bottom alignment for e.g. anchors and layouts. -#[derive(Clone, Copy, Debug, PartialEq, Eq, Hash)] +#[derive(Clone, Copy, Debug, Default, PartialEq, Eq, Hash)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum Align { /// Left or top. + #[default] Min, /// Horizontal or vertical center. @@ -136,13 +137,6 @@ impl Align { } } -impl Default for Align { - #[inline(always)] - fn default() -> Align { - Align::Min - } -} - // ---------------------------------------------------------------------------- /// Two-dimension alignment, e.g. [`Align2::LEFT_TOP`]. diff --git a/crates/epaint/src/text/fonts.rs b/crates/epaint/src/text/fonts.rs index 68dd5812..829a593f 100644 --- a/crates/epaint/src/text/fonts.rs +++ b/crates/epaint/src/text/fonts.rs @@ -67,12 +67,13 @@ impl std::hash::Hash for FontId { /// /// Which style of font: [`Monospace`][`FontFamily::Monospace`], [`Proportional`][`FontFamily::Proportional`], /// or by user-chosen name. -#[derive(Clone, Debug, Eq, Hash, Ord, PartialEq, PartialOrd)] +#[derive(Clone, Debug, Default, Eq, Hash, Ord, PartialEq, PartialOrd)] #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))] pub enum FontFamily { /// A font where some characters are wider than other (e.g. 'w' is wider than 'i'). /// /// Proportional fonts are easier to read and should be the preferred choice in most situations. + #[default] Proportional, /// A font where each character is the same width (`w` is the same width as `i`). @@ -91,13 +92,6 @@ pub enum FontFamily { Name(Arc), } -impl Default for FontFamily { - #[inline] - fn default() -> Self { - FontFamily::Proportional - } -} - impl std::fmt::Display for FontFamily { fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { match self { diff --git a/examples/confirm_exit/src/main.rs b/examples/confirm_exit/src/main.rs index 79927c49..05b45bd0 100644 --- a/examples/confirm_exit/src/main.rs +++ b/examples/confirm_exit/src/main.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Confirm exit", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/custom_3d_glow/src/main.rs b/examples/custom_3d_glow/src/main.rs index d57bffe0..f72859d2 100644 --- a/examples/custom_3d_glow/src/main.rs +++ b/examples/custom_3d_glow/src/main.rs @@ -157,9 +157,11 @@ impl RotatingTriangle { .collect(); gl.link_program(program); - if !gl.get_program_link_status(program) { - panic!("{}", gl.get_program_info_log(program)); - } + assert!( + gl.get_program_link_status(program), + "{}", + gl.get_program_info_log(program) + ); for shader in shaders { gl.detach_shader(program, shader); diff --git a/examples/custom_window_frame/src/main.rs b/examples/custom_window_frame/src/main.rs index 2b1910d8..8ea32fbf 100644 --- a/examples/custom_window_frame/src/main.rs +++ b/examples/custom_window_frame/src/main.rs @@ -18,7 +18,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Custom window frame", // unused title options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/download_image/src/main.rs b/examples/download_image/src/main.rs index 10af2581..2a2c3540 100644 --- a/examples/download_image/src/main.rs +++ b/examples/download_image/src/main.rs @@ -10,7 +10,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Download and show an image with eframe/egui", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/file_dialog/src/main.rs b/examples/file_dialog/src/main.rs index f2465e64..77f88872 100644 --- a/examples/file_dialog/src/main.rs +++ b/examples/file_dialog/src/main.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Native file dialogs and drag-and-drop files", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/hello_world/src/main.rs b/examples/hello_world/src/main.rs index 5430caaf..47c045db 100644 --- a/examples/hello_world/src/main.rs +++ b/examples/hello_world/src/main.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "My egui App", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/keyboard_events/src/main.rs b/examples/keyboard_events/src/main.rs index a1beccac..a51bf190 100644 --- a/examples/keyboard_events/src/main.rs +++ b/examples/keyboard_events/src/main.rs @@ -9,7 +9,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Keyboard events", options, - Box::new(|_cc| Box::new(Content::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/puffin_profiler/src/main.rs b/examples/puffin_profiler/src/main.rs index e41ffea0..2cfc5e61 100644 --- a/examples/puffin_profiler/src/main.rs +++ b/examples/puffin_profiler/src/main.rs @@ -9,7 +9,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "My egui App", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/retained_image/src/main.rs b/examples/retained_image/src/main.rs index d7703984..148217fc 100644 --- a/examples/retained_image/src/main.rs +++ b/examples/retained_image/src/main.rs @@ -12,7 +12,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Show an image with eframe/egui", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/screenshot/src/main.rs b/examples/screenshot/src/main.rs index cbe0400a..4dff5326 100644 --- a/examples/screenshot/src/main.rs +++ b/examples/screenshot/src/main.rs @@ -11,7 +11,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "Take screenshots and display with eframe/egui", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) } diff --git a/examples/svg/src/main.rs b/examples/svg/src/main.rs index a41d2529..5629f803 100644 --- a/examples/svg/src/main.rs +++ b/examples/svg/src/main.rs @@ -15,7 +15,7 @@ fn main() -> Result<(), eframe::Error> { eframe::run_native( "svg example", options, - Box::new(|_cc| Box::new(MyApp::default())), + Box::new(|_cc| Box::::default()), ) }