clippy fixes from 1.69.0

This commit is contained in:
Emil Ernerfeldt 2023-04-21 11:33:18 +02:00
parent 4d360f67a4
commit 4d357b0f02
17 changed files with 53 additions and 61 deletions

View File

@ -126,7 +126,7 @@ impl CacheStorage {
pub fn cache<FrameCache: CacheTrait + Default>(&mut self) -> &mut FrameCache {
self.caches
.entry(std::any::TypeId::of::<FrameCache>())
.or_insert_with(|| Box::new(FrameCache::default()))
.or_insert_with(|| Box::<FrameCache>::default())
.as_any_mut()
.downcast_mut::<FrameCache>()
.unwrap()

View File

@ -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);

View File

@ -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::<super::paint_bezier::PaintBezier>::default(),
Box::<super::code_editor::CodeEditor>::default(),
Box::<super::code_example::CodeExample>::default(),
Box::<super::context_menu::ContextMenus>::default(),
Box::<super::dancing_strings::DancingStrings>::default(),
Box::<super::drag_and_drop::DragAndDropDemo>::default(),
Box::<super::font_book::FontBook>::default(),
Box::<super::MiscDemoWindow>::default(),
Box::<super::multi_touch::MultiTouch>::default(),
Box::<super::painting::Painting>::default(),
Box::<super::plot_demo::PlotDemo>::default(),
Box::<super::scrolling::Scrolling>::default(),
Box::<super::sliders::Sliders>::default(),
Box::<super::strip_demo::StripDemo>::default(),
Box::<super::table_demo::TableDemo>::default(),
Box::<super::text_edit::TextEdit>::default(),
Box::<super::widget_gallery::WidgetGallery>::default(),
Box::<super::window_options::WindowOptions>::default(),
Box::<super::tests::WindowResizeTest>::default(),
Box::<super::window_with_panels::WindowWithPanels>::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::<super::tests::CursorTest>::default(),
Box::<super::highlighting::Highlighting>::default(),
Box::<super::tests::IdTest>::default(),
Box::<super::tests::InputTest>::default(),
Box::<super::layout_test::LayoutTest>::default(),
Box::<super::tests::ManualLayoutTest>::default(),
Box::<super::tests::TableTest>::default(),
])
}
}

View File

@ -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());

View File

@ -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`].

View File

@ -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<str>),
}
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 {

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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);

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<Content>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}

View File

@ -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::<MyApp>::default()),
)
}