Skip to content

Commit 164f56f

Browse files
authored
Fix some clippy issues found by 1.84.0 (#5603)
1 parent 1339639 commit 164f56f

File tree

33 files changed

+65
-81
lines changed

33 files changed

+65
-81
lines changed

crates/eframe/src/epi.rs

Lines changed: 0 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -878,20 +878,6 @@ pub trait Storage {
878878
fn flush(&mut self);
879879
}
880880

881-
/// Stores nothing.
882-
#[derive(Clone, Default)]
883-
pub(crate) struct DummyStorage {}
884-
885-
impl Storage for DummyStorage {
886-
fn get_string(&self, _key: &str) -> Option<String> {
887-
None
888-
}
889-
890-
fn set_string(&mut self, _key: &str, _value: String) {}
891-
892-
fn flush(&mut self) {}
893-
}
894-
895881
/// Get and deserialize the [RON](https://github.com/ron-rs/ron) stored at the given key.
896882
#[cfg(feature = "ron")]
897883
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {

crates/eframe/src/native/glow_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -344,7 +344,7 @@ impl<'app> GlowWinitApp<'app> {
344344
}
345345
}
346346

347-
impl<'app> WinitApp for GlowWinitApp<'app> {
347+
impl WinitApp for GlowWinitApp<'_> {
348348
fn egui_ctx(&self) -> Option<&egui::Context> {
349349
self.running.as_ref().map(|r| &r.integration.egui_ctx)
350350
}
@@ -479,7 +479,7 @@ impl<'app> WinitApp for GlowWinitApp<'app> {
479479
}
480480
}
481481

482-
impl<'app> GlowWinitRunning<'app> {
482+
impl GlowWinitRunning<'_> {
483483
fn run_ui_and_paint(
484484
&mut self,
485485
event_loop: &ActiveEventLoop,

crates/eframe/src/native/wgpu_integration.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -323,7 +323,7 @@ impl<'app> WgpuWinitApp<'app> {
323323
}
324324
}
325325

326-
impl<'app> WinitApp for WgpuWinitApp<'app> {
326+
impl WinitApp for WgpuWinitApp<'_> {
327327
fn egui_ctx(&self) -> Option<&egui::Context> {
328328
self.running.as_ref().map(|r| &r.integration.egui_ctx)
329329
}
@@ -487,7 +487,7 @@ impl<'app> WinitApp for WgpuWinitApp<'app> {
487487
}
488488
}
489489

490-
impl<'app> WgpuWinitRunning<'app> {
490+
impl WgpuWinitRunning<'_> {
491491
fn save_and_destroy(&mut self) {
492492
profiling::function_scope!();
493493

crates/egui-wgpu/src/setup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ impl WgpuSetup {
5555
#[cfg(target_arch = "wasm32")]
5656
if backends.contains(wgpu::Backends::BROWSER_WEBGPU) {
5757
let is_secure_context =
58-
wgpu::web_sys::window().map_or(false, |w| w.is_secure_context());
58+
wgpu::web_sys::window().is_some_and(|w| w.is_secure_context());
5959
if !is_secure_context {
6060
log::info!(
6161
"WebGPU is only available in secure contexts, i.e. on HTTPS and on localhost."

crates/egui/src/containers/collapsing_header.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,7 +283,7 @@ pub struct HeaderResponse<'ui, HeaderRet> {
283283
header_response: InnerResponse<HeaderRet>,
284284
}
285285

286-
impl<'ui, HeaderRet> HeaderResponse<'ui, HeaderRet> {
286+
impl<HeaderRet> HeaderResponse<'_, HeaderRet> {
287287
pub fn is_open(&self) -> bool {
288288
self.state.is_open()
289289
}

crates/egui/src/containers/scroll_area.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1184,7 +1184,7 @@ impl Prepared {
11841184
&& ui.input(|i| {
11851185
i.pointer
11861186
.latest_pos()
1187-
.map_or(false, |p| handle_rect.contains(p))
1187+
.is_some_and(|p| handle_rect.contains(p))
11881188
});
11891189
let visuals = ui.visuals();
11901190
if response.is_pointer_button_down_on() {

crates/egui/src/containers/window.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -415,7 +415,7 @@ impl<'open> Window<'open> {
415415
}
416416
}
417417

418-
impl<'open> Window<'open> {
418+
impl Window<'_> {
419419
/// Returns `None` if the window is not open (if [`Window::open`] was called with `&mut false`).
420420
/// Returns `Some(InnerResponse { inner: None })` if the window is collapsed.
421421
#[inline]

crates/egui/src/context.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -211,14 +211,14 @@ impl ContextImpl {
211211
fn requested_immediate_repaint_prev_pass(&self, viewport_id: &ViewportId) -> bool {
212212
self.viewports
213213
.get(viewport_id)
214-
.map_or(false, |v| v.repaint.requested_immediate_repaint_prev_pass())
214+
.is_some_and(|v| v.repaint.requested_immediate_repaint_prev_pass())
215215
}
216216

217217
#[must_use]
218218
fn has_requested_repaint(&self, viewport_id: &ViewportId) -> bool {
219-
self.viewports.get(viewport_id).map_or(false, |v| {
220-
0 < v.repaint.outstanding || v.repaint.repaint_delay < Duration::MAX
221-
})
219+
self.viewports
220+
.get(viewport_id)
221+
.is_some_and(|v| 0 < v.repaint.outstanding || v.repaint.repaint_delay < Duration::MAX)
222222
}
223223
}
224224

@@ -1214,7 +1214,7 @@ impl Context {
12141214
#[deprecated = "Use Response.contains_pointer or Context::read_response instead"]
12151215
pub fn widget_contains_pointer(&self, id: Id) -> bool {
12161216
self.read_response(id)
1217-
.map_or(false, |response| response.contains_pointer())
1217+
.is_some_and(|response| response.contains_pointer())
12181218
}
12191219

12201220
/// Do all interaction for an existing widget, without (re-)registering it.
@@ -2632,7 +2632,7 @@ impl Context {
26322632
pub fn is_context_menu_open(&self) -> bool {
26332633
self.data(|d| {
26342634
d.get_temp::<crate::menu::BarState>(menu::CONTEXT_MENU_ID_STR.into())
2635-
.map_or(false, |state| state.has_root())
2635+
.is_some_and(|state| state.has_root())
26362636
})
26372637
}
26382638
}

crates/egui/src/data/input.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -986,7 +986,7 @@ impl ModifierNames<'static> {
986986
};
987987
}
988988

989-
impl<'a> ModifierNames<'a> {
989+
impl ModifierNames<'_> {
990990
pub fn format(&self, modifiers: &Modifiers, is_mac: bool) -> String {
991991
let mut s = String::new();
992992

crates/egui/src/data/user_data.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ impl<'de> serde::Deserialize<'de> for UserData {
5454
{
5555
struct UserDataVisitor;
5656

57-
impl<'de> serde::de::Visitor<'de> for UserDataVisitor {
57+
impl serde::de::Visitor<'_> for UserDataVisitor {
5858
type Value = UserData;
5959

6060
fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {

crates/egui/src/drag_and_drop.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ impl DragAndDrop {
141141
pub fn has_any_payload(ctx: &Context) -> bool {
142142
ctx.data(|data| {
143143
let state = data.get_temp::<Self>(Id::NULL);
144-
state.map_or(false, |state| state.payload.is_some())
144+
state.is_some_and(|state| state.payload.is_some())
145145
})
146146
}
147147
}

crates/egui/src/input_state/mod.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1303,7 +1303,7 @@ impl PointerState {
13031303
self.started_decidedly_dragging
13041304
&& !self.has_moved_too_much_for_a_click
13051305
&& self.button_down(PointerButton::Primary)
1306-
&& self.press_start_time.map_or(false, |press_start_time| {
1306+
&& self.press_start_time.is_some_and(|press_start_time| {
13071307
self.time - press_start_time > self.input_options.max_click_duration
13081308
})
13091309
}

crates/egui/src/menu.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -679,7 +679,7 @@ impl MenuState {
679679
|| self
680680
.sub_menu
681681
.as_ref()
682-
.map_or(false, |(_, sub)| sub.read().area_contains(pos))
682+
.is_some_and(|(_, sub)| sub.read().area_contains(pos))
683683
}
684684

685685
fn next_entry_index(&mut self) -> usize {

crates/egui/src/response.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -618,7 +618,7 @@ impl Response {
618618
let any_open_popups = self.ctx.prev_pass_state(|fs| {
619619
fs.layers
620620
.get(&self.layer_id)
621-
.map_or(false, |layer| !layer.open_popups.is_empty())
621+
.is_some_and(|layer| !layer.open_popups.is_empty())
622622
});
623623
if any_open_popups {
624624
// Hide tooltips if the user opens a popup (menu, combo-box, etc) in the same layer.

crates/egui/src/text_selection/label_text_selection.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -263,7 +263,7 @@ impl LabelSelectionState {
263263
let new_text_starts_with_space_or_punctuation = new_text
264264
.chars()
265265
.next()
266-
.map_or(false, |c| c.is_whitespace() || c.is_ascii_punctuation());
266+
.is_some_and(|c| c.is_whitespace() || c.is_ascii_punctuation());
267267

268268
if existing_ends_with_space == Some(false) && !new_text_starts_with_space_or_punctuation
269269
{

crates/egui/src/ui_stack.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -229,13 +229,13 @@ impl UiStack {
229229
/// Is this [`crate::Ui`] a panel?
230230
#[inline]
231231
pub fn is_panel_ui(&self) -> bool {
232-
self.kind().map_or(false, |kind| kind.is_panel())
232+
self.kind().is_some_and(|kind| kind.is_panel())
233233
}
234234

235235
/// Is this [`crate::Ui`] an [`crate::Area`]?
236236
#[inline]
237237
pub fn is_area_ui(&self) -> bool {
238-
self.kind().map_or(false, |kind| kind.is_area())
238+
self.kind().is_some_and(|kind| kind.is_area())
239239
}
240240

241241
/// Is this a root [`crate::Ui`], i.e. created with [`crate::Ui::new()`]?
@@ -285,4 +285,4 @@ impl<'a> Iterator for UiStackIterator<'a> {
285285
}
286286
}
287287

288-
impl<'a> FusedIterator for UiStackIterator<'a> {}
288+
impl FusedIterator for UiStackIterator<'_> {}

crates/egui/src/widgets/checkbox.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ impl<'a> Checkbox<'a> {
4747
}
4848
}
4949

50-
impl<'a> Widget for Checkbox<'a> {
50+
impl Widget for Checkbox<'_> {
5151
fn ui(self, ui: &mut Ui) -> Response {
5252
let Checkbox {
5353
checked,

crates/egui/src/widgets/drag_value.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -426,7 +426,7 @@ impl<'a> DragValue<'a> {
426426
}
427427
}
428428

429-
impl<'a> Widget for DragValue<'a> {
429+
impl Widget for DragValue<'_> {
430430
fn ui(self, ui: &mut Ui) -> Response {
431431
let Self {
432432
mut get_set_value,

crates/egui/src/widgets/image.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -372,7 +372,7 @@ impl<'a> Image<'a> {
372372
}
373373
}
374374

375-
impl<'a> Widget for Image<'a> {
375+
impl Widget for Image<'_> {
376376
fn ui(self, ui: &mut Ui) -> Response {
377377
let tlr = self.load_for_size(ui.ctx(), ui.available_size());
378378
let original_image_size = tlr.as_ref().ok().and_then(|t| t.size());
@@ -568,7 +568,7 @@ pub enum ImageSource<'a> {
568568
},
569569
}
570570

571-
impl<'a> std::fmt::Debug for ImageSource<'a> {
571+
impl std::fmt::Debug for ImageSource<'_> {
572572
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
573573
match self {
574574
ImageSource::Bytes { uri, .. } | ImageSource::Uri(uri) => uri.as_ref().fmt(f),
@@ -577,7 +577,7 @@ impl<'a> std::fmt::Debug for ImageSource<'a> {
577577
}
578578
}
579579

580-
impl<'a> ImageSource<'a> {
580+
impl ImageSource<'_> {
581581
/// Size of the texture, if known.
582582
#[inline]
583583
pub fn texture_size(&self) -> Option<Vec2> {

crates/egui/src/widgets/image_button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@ impl<'a> ImageButton<'a> {
7171
}
7272
}
7373

74-
impl<'a> Widget for ImageButton<'a> {
74+
impl Widget for ImageButton<'_> {
7575
fn ui(self, ui: &mut Ui) -> Response {
7676
let padding = if self.frame {
7777
// so we can see that it is a button:

crates/egui/src/widgets/label.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -244,7 +244,7 @@ impl Widget for Label {
244244
// Interactive = the uses asked to sense interaction.
245245
// We DON'T want to have the color respond just because the text is selectable;
246246
// the cursor is enough to communicate that.
247-
let interactive = self.sense.map_or(false, |sense| sense != Sense::hover());
247+
let interactive = self.sense.is_some_and(|sense| sense != Sense::hover());
248248

249249
let selectable = self.selectable;
250250

crates/egui/src/widgets/slider.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -643,7 +643,7 @@ impl<'a> Slider<'a> {
643643
}
644644
}
645645

646-
impl<'a> Slider<'a> {
646+
impl Slider<'_> {
647647
/// Just the slider, no text
648648
fn allocate_slider_space(&self, ui: &mut Ui, thickness: f32) -> Response {
649649
let desired_size = match self.orientation {
@@ -1015,7 +1015,7 @@ impl<'a> Slider<'a> {
10151015
}
10161016
}
10171017

1018-
impl<'a> Widget for Slider<'a> {
1018+
impl Widget for Slider<'_> {
10191019
fn ui(mut self, ui: &mut Ui) -> Response {
10201020
let inner_response = match self.orientation {
10211021
SliderOrientation::Horizontal => ui.horizontal(|ui| self.add_contents(ui)),

crates/egui/src/widgets/text_edit/builder.rs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -88,11 +88,11 @@ pub struct TextEdit<'t> {
8888
background_color: Option<Color32>,
8989
}
9090

91-
impl<'t> WidgetWithState for TextEdit<'t> {
91+
impl WidgetWithState for TextEdit<'_> {
9292
type State = TextEditState;
9393
}
9494

95-
impl<'t> TextEdit<'t> {
95+
impl TextEdit<'_> {
9696
pub fn load_state(ctx: &Context, id: Id) -> Option<TextEditState> {
9797
TextEditState::load(ctx, id)
9898
}
@@ -394,13 +394,13 @@ impl<'t> TextEdit<'t> {
394394

395395
// ----------------------------------------------------------------------------
396396

397-
impl<'t> Widget for TextEdit<'t> {
397+
impl Widget for TextEdit<'_> {
398398
fn ui(self, ui: &mut Ui) -> Response {
399399
self.show(ui).response
400400
}
401401
}
402402

403-
impl<'t> TextEdit<'t> {
403+
impl TextEdit<'_> {
404404
/// Show the [`TextEdit`], returning a rich [`TextEditOutput`].
405405
///
406406
/// ```

crates/egui/src/widgets/text_edit/text_buffer.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -228,7 +228,7 @@ impl TextBuffer for String {
228228
}
229229
}
230230

231-
impl<'a> TextBuffer for Cow<'a, str> {
231+
impl TextBuffer for Cow<'_, str> {
232232
fn is_mutable(&self) -> bool {
233233
true
234234
}
@@ -259,7 +259,7 @@ impl<'a> TextBuffer for Cow<'a, str> {
259259
}
260260

261261
/// Immutable view of a `&str`!
262-
impl<'a> TextBuffer for &'a str {
262+
impl TextBuffer for &str {
263263
fn is_mutable(&self) -> bool {
264264
false
265265
}

crates/egui_demo_lib/src/demo/text_edit.rs

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,7 @@ impl crate::View for TextEditDemo {
5858
}
5959
});
6060

61-
let anything_selected = output
62-
.cursor_range
63-
.map_or(false, |cursor| !cursor.is_empty());
61+
let anything_selected = output.cursor_range.is_some_and(|cursor| !cursor.is_empty());
6462

6563
ui.add_enabled(
6664
anything_selected,

crates/egui_extras/src/datepicker/button.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@ impl<'a> DatePickerButton<'a> {
103103
}
104104
}
105105

106-
impl<'a> Widget for DatePickerButton<'a> {
106+
impl Widget for DatePickerButton<'_> {
107107
fn ui(self, ui: &mut Ui) -> egui::Response {
108108
let id = ui.make_persistent_id(self.id_salt);
109109
let mut button_state = ui

crates/egui_extras/src/datepicker/popup.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ pub(crate) struct DatePickerPopup<'a> {
3737
pub highlight_weekends: bool,
3838
}
3939

40-
impl<'a> DatePickerPopup<'a> {
40+
impl DatePickerPopup<'_> {
4141
/// Returns `true` if user pressed `Save` button.
4242
pub fn draw(&mut self, ui: &mut Ui) -> bool {
4343
let id = ui.make_persistent_id("date_picker");

crates/egui_extras/src/strip.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -166,7 +166,7 @@ pub struct Strip<'a, 'b> {
166166
size_index: usize,
167167
}
168168

169-
impl<'a, 'b> Strip<'a, 'b> {
169+
impl Strip<'_, '_> {
170170
#[cfg_attr(debug_assertions, track_caller)]
171171
fn next_cell_size(&mut self) -> (CellSize, CellSize) {
172172
let size = if let Some(size) = self.sizes.get(self.size_index) {
@@ -219,7 +219,7 @@ impl<'a, 'b> Strip<'a, 'b> {
219219
}
220220
}
221221

222-
impl<'a, 'b> Drop for Strip<'a, 'b> {
222+
impl Drop for Strip<'_, '_> {
223223
fn drop(&mut self) {
224224
while self.size_index < self.sizes.len() {
225225
self.empty();

0 commit comments

Comments
 (0)