mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 05:40:03 -04:00
Enable and fix some more clippy lints (#7426)
One can never have too many lints
This commit is contained in:
@@ -893,16 +893,15 @@ pub trait Storage {
|
||||
#[cfg(feature = "ron")]
|
||||
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
|
||||
profiling::function_scope!(key);
|
||||
storage
|
||||
.get_string(key)
|
||||
.and_then(|value| match ron::from_str(&value) {
|
||||
Ok(value) => Some(value),
|
||||
Err(err) => {
|
||||
// This happens on when we break the format, e.g. when updating egui.
|
||||
log::debug!("Failed to decode RON: {err}");
|
||||
None
|
||||
}
|
||||
})
|
||||
let value = storage.get_string(key)?;
|
||||
match ron::from_str(&value) {
|
||||
Ok(value) => Some(value),
|
||||
Err(err) => {
|
||||
// This happens on when we break the format, e.g. when updating egui.
|
||||
log::debug!("Failed to decode RON: {err}");
|
||||
None
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Serialize the given value as [RON](https://github.com/ron-rs/ron) and store with the given key.
|
||||
|
||||
@@ -336,10 +336,10 @@ impl<'app> GlowWinitApp<'app> {
|
||||
}
|
||||
|
||||
Ok(self.running.insert(GlowWinitRunning {
|
||||
glutin,
|
||||
painter,
|
||||
integration,
|
||||
app,
|
||||
glutin,
|
||||
painter,
|
||||
}))
|
||||
}
|
||||
}
|
||||
@@ -362,8 +362,12 @@ impl WinitApp for GlowWinitApp<'_> {
|
||||
|
||||
fn window_id_from_viewport_id(&self, id: ViewportId) -> Option<WindowId> {
|
||||
self.running
|
||||
.as_ref()
|
||||
.and_then(|r| r.glutin.borrow().window_from_viewport.get(&id).copied())
|
||||
.as_ref()?
|
||||
.glutin
|
||||
.borrow()
|
||||
.window_from_viewport
|
||||
.get(&id)
|
||||
.copied()
|
||||
}
|
||||
|
||||
fn save(&mut self) {
|
||||
|
||||
@@ -145,7 +145,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||
log::error!("Exiting because of error: {err}");
|
||||
exit = true;
|
||||
self.return_result = Err(err);
|
||||
};
|
||||
}
|
||||
|
||||
if save {
|
||||
log::debug!("Received an EventResult::Save - saving app state");
|
||||
@@ -176,7 +176,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||
.retain(|window_id, repaint_time| {
|
||||
if now < *repaint_time {
|
||||
return true; // not yet ready
|
||||
};
|
||||
}
|
||||
|
||||
event_loop.set_control_flow(ControlFlow::Poll);
|
||||
|
||||
@@ -192,7 +192,7 @@ impl<T: WinitApp> WinitAppWrapper<T> {
|
||||
let next_repaint_time = self.windows_next_repaint_times.values().min().copied();
|
||||
if let Some(next_repaint_time) = next_repaint_time {
|
||||
event_loop.set_control_flow(ControlFlow::WaitUntil(next_repaint_time));
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -333,10 +333,8 @@ impl WinitApp for WgpuWinitApp<'_> {
|
||||
.as_ref()
|
||||
.and_then(|r| {
|
||||
let shared = r.shared.borrow();
|
||||
shared
|
||||
.viewport_from_window
|
||||
.get(&window_id)
|
||||
.and_then(|id| shared.viewports.get(id).map(|v| v.window.clone()))
|
||||
let id = shared.viewport_from_window.get(&window_id)?;
|
||||
shared.viewports.get(id).map(|v| v.window.clone())
|
||||
})
|
||||
.flatten()
|
||||
}
|
||||
@@ -821,17 +819,16 @@ impl WgpuWinitRunning<'_> {
|
||||
}
|
||||
|
||||
_ => {}
|
||||
};
|
||||
}
|
||||
|
||||
let event_response = viewport_id
|
||||
.and_then(|viewport_id| {
|
||||
shared.viewports.get_mut(&viewport_id).and_then(|viewport| {
|
||||
Some(integration.on_window_event(
|
||||
viewport.window.as_deref()?,
|
||||
viewport.egui_winit.as_mut()?,
|
||||
event,
|
||||
))
|
||||
})
|
||||
let viewport = shared.viewports.get_mut(&viewport_id)?;
|
||||
Some(integration.on_window_event(
|
||||
viewport.window.as_deref()?,
|
||||
viewport.egui_winit.as_mut()?,
|
||||
event,
|
||||
))
|
||||
})
|
||||
.unwrap_or_default();
|
||||
|
||||
|
||||
Reference in New Issue
Block a user