mirror of
https://github.com/emilk/egui.git
synced 2026-09-01 22:30:03 -04:00
Enable and fix some more clippy lints
This commit is contained in:
@@ -230,7 +230,7 @@ impl Area {
|
||||
|
||||
let layer_id = LayerId::new(order, id);
|
||||
|
||||
let state = ctx.memory().areas.get(id).cloned();
|
||||
let state = ctx.memory().areas.get(id).copied();
|
||||
let is_new = state.is_none();
|
||||
if is_new {
|
||||
ctx.request_repaint(); // if we don't know the previous size we are likely drawing the area in the wrong place
|
||||
|
||||
@@ -44,7 +44,7 @@ impl PanelState {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// [`Left`](Side::Left) or [`Right`](Side::Right)
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum Side {
|
||||
Left,
|
||||
Right,
|
||||
@@ -468,7 +468,7 @@ impl SidePanel {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// [`Top`](TopBottomSide::Top) or [`Bottom`](TopBottomSide::Bottom)
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub enum TopBottomSide {
|
||||
Top,
|
||||
Bottom,
|
||||
|
||||
@@ -22,7 +22,7 @@ impl TooltipState {
|
||||
|
||||
fn individual_tooltip_size(&self, common_id: Id, index: usize) -> Option<Vec2> {
|
||||
if self.last_common_id == Some(common_id) {
|
||||
Some(self.individual_ids_and_sizes.get(&index).cloned()?.1)
|
||||
Some(self.individual_ids_and_sizes.get(&index)?.1)
|
||||
} else {
|
||||
None
|
||||
}
|
||||
|
||||
@@ -1513,7 +1513,7 @@ impl Context {
|
||||
ui.label("Hover to highlight");
|
||||
let layers_ids: Vec<LayerId> = self.memory().areas.order().to_vec();
|
||||
for layer_id in layers_ids {
|
||||
let area = self.memory().areas.get(layer_id.id).cloned();
|
||||
let area = self.memory().areas.get(layer_id.id).copied();
|
||||
if let Some(area) = area {
|
||||
let is_visible = self.memory().areas.is_visible(&layer_id);
|
||||
if !is_visible {
|
||||
|
||||
@@ -133,7 +133,7 @@ impl RawInput {
|
||||
}
|
||||
|
||||
/// A file about to be dropped into egui.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct HoveredFile {
|
||||
/// Set by the `egui-winit` backend.
|
||||
@@ -144,7 +144,7 @@ pub struct HoveredFile {
|
||||
}
|
||||
|
||||
/// A file dropped into egui.
|
||||
#[derive(Clone, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct DroppedFile {
|
||||
/// Set by the `egui-winit` backend.
|
||||
@@ -305,7 +305,7 @@ pub const NUM_POINTER_BUTTONS: usize = 5;
|
||||
/// NOTE: For cross-platform uses, ALT+SHIFT is a bad combination of modifiers
|
||||
/// as on mac that is how you type special characters,
|
||||
/// so those key presses are usually not reported to egui.
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Modifiers {
|
||||
/// Either of the alt keys are down (option ⌥ on Mac).
|
||||
@@ -768,7 +768,7 @@ impl Key {
|
||||
///
|
||||
/// Can be used with [`crate::InputState::consume_shortcut`]
|
||||
/// and [`crate::Context::format_shortcut`].
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
pub struct KeyboardShortcut {
|
||||
pub modifiers: Modifiers,
|
||||
pub key: Key,
|
||||
|
||||
@@ -156,7 +156,7 @@ impl PlatformOutput {
|
||||
}
|
||||
|
||||
/// What URL to open, and how.
|
||||
#[derive(Clone, PartialEq)]
|
||||
#[derive(Clone, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct OpenUrl {
|
||||
pub url: String,
|
||||
@@ -190,7 +190,7 @@ impl OpenUrl {
|
||||
/// egui emits a [`CursorIcon`] in [`PlatformOutput`] each frame as a request to the integration.
|
||||
///
|
||||
/// Loosely based on <https://developer.mozilla.org/en-US/docs/Web/CSS/cursor>.
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum CursorIcon {
|
||||
/// Normal cursor icon, whatever that is.
|
||||
|
||||
@@ -109,7 +109,7 @@ impl LayerId {
|
||||
}
|
||||
|
||||
/// A unique identifier of a specific [`Shape`] in a [`PaintList`].
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub struct ShapeIdx(usize);
|
||||
|
||||
/// A list of [`Shape`]s paired with a clip rectangle.
|
||||
|
||||
@@ -75,7 +75,7 @@ impl Region {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
/// Layout direction, one of [`LeftToRight`](Direction::LeftToRight), [`RightToLeft`](Direction::RightToLeft), [`TopDown`](Direction::TopDown), [`BottomUp`](Direction::BottomUp).
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum Direction {
|
||||
LeftToRight,
|
||||
@@ -114,7 +114,7 @@ impl Direction {
|
||||
/// });
|
||||
/// # });
|
||||
/// ```
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
// #[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct Layout {
|
||||
/// Main axis direction
|
||||
|
||||
@@ -507,7 +507,7 @@ pub mod special_emojis {
|
||||
}
|
||||
|
||||
/// The different types of built-in widgets in egui
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub enum WidgetType {
|
||||
Label, // TODO(emilk): emit Label events
|
||||
|
||||
@@ -587,8 +587,8 @@ impl Areas {
|
||||
pub fn visible_layer_ids(&self) -> ahash::HashSet<LayerId> {
|
||||
self.visible_last_frame
|
||||
.iter()
|
||||
.cloned()
|
||||
.chain(self.visible_current_frame.iter().cloned())
|
||||
.copied()
|
||||
.chain(self.visible_current_frame.iter().copied())
|
||||
.collect()
|
||||
}
|
||||
|
||||
|
||||
@@ -592,7 +592,7 @@ impl WidgetVisuals {
|
||||
}
|
||||
|
||||
/// Options for help debug egui by adding extra visualization
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq)]
|
||||
#[derive(Clone, Copy, Debug, Default, PartialEq, Eq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
pub struct DebugOptions {
|
||||
/// However over widgets to see their rectangles
|
||||
|
||||
@@ -211,7 +211,7 @@ fn color_slider_2d(
|
||||
}
|
||||
|
||||
/// What options to show for alpha
|
||||
#[derive(Clone, Copy, PartialEq)]
|
||||
#[derive(Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Alpha {
|
||||
// Set alpha to 1.0, and show no option for it.
|
||||
Opaque,
|
||||
@@ -425,7 +425,7 @@ pub fn color_edit_button_rgb(ui: &mut Ui, rgb: &mut [f32; 3]) -> Response {
|
||||
// To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
|
||||
fn color_cache_get(ctx: &Context, rgba: impl Into<Rgba>) -> Hsva {
|
||||
let rgba = rgba.into();
|
||||
use_color_cache(ctx, |cc| cc.get(&rgba).cloned()).unwrap_or_else(|| Hsva::from(rgba))
|
||||
use_color_cache(ctx, |cc| cc.get(&rgba).copied()).unwrap_or_else(|| Hsva::from(rgba))
|
||||
}
|
||||
|
||||
// To ensure we keep hue slider when `srgba` is gray we store the full [`Hsva`] in a cache:
|
||||
|
||||
@@ -5,7 +5,7 @@ use crate::*;
|
||||
use super::items::PlotItem;
|
||||
|
||||
/// Where to place the plot legend.
|
||||
#[derive(Debug, Clone, Copy, PartialEq)]
|
||||
#[derive(Debug, Clone, Copy, PartialEq, Eq)]
|
||||
pub enum Corner {
|
||||
LeftTop,
|
||||
RightTop,
|
||||
|
||||
Reference in New Issue
Block a user