Skip to content

Commit

Permalink
Merge branch 'emilk:master' into patch9
Browse files Browse the repository at this point in the history
  • Loading branch information
rustbasic authored Jan 13, 2025
2 parents 2af848c + 164f56f commit 7af0d5d
Show file tree
Hide file tree
Showing 33 changed files with 65 additions and 81 deletions.
14 changes: 0 additions & 14 deletions crates/eframe/src/epi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -878,20 +878,6 @@ pub trait Storage {
fn flush(&mut self);
}

/// Stores nothing.
#[derive(Clone, Default)]
pub(crate) struct DummyStorage {}

impl Storage for DummyStorage {
fn get_string(&self, _key: &str) -> Option<String> {
None
}

fn set_string(&mut self, _key: &str, _value: String) {}

fn flush(&mut self) {}
}

/// Get and deserialize the [RON](https://github.com/ron-rs/ron) stored at the given key.
#[cfg(feature = "ron")]
pub fn get_value<T: serde::de::DeserializeOwned>(storage: &dyn Storage, key: &str) -> Option<T> {
Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/native/glow_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -344,7 +344,7 @@ impl<'app> GlowWinitApp<'app> {
}
}

impl<'app> WinitApp for GlowWinitApp<'app> {
impl WinitApp for GlowWinitApp<'_> {
fn egui_ctx(&self) -> Option<&egui::Context> {
self.running.as_ref().map(|r| &r.integration.egui_ctx)
}
Expand Down Expand Up @@ -479,7 +479,7 @@ impl<'app> WinitApp for GlowWinitApp<'app> {
}
}

impl<'app> GlowWinitRunning<'app> {
impl GlowWinitRunning<'_> {
fn run_ui_and_paint(
&mut self,
event_loop: &ActiveEventLoop,
Expand Down
4 changes: 2 additions & 2 deletions crates/eframe/src/native/wgpu_integration.rs
Original file line number Diff line number Diff line change
Expand Up @@ -323,7 +323,7 @@ impl<'app> WgpuWinitApp<'app> {
}
}

impl<'app> WinitApp for WgpuWinitApp<'app> {
impl WinitApp for WgpuWinitApp<'_> {
fn egui_ctx(&self) -> Option<&egui::Context> {
self.running.as_ref().map(|r| &r.integration.egui_ctx)
}
Expand Down Expand Up @@ -487,7 +487,7 @@ impl<'app> WinitApp for WgpuWinitApp<'app> {
}
}

impl<'app> WgpuWinitRunning<'app> {
impl WgpuWinitRunning<'_> {
fn save_and_destroy(&mut self) {
profiling::function_scope!();

Expand Down
2 changes: 1 addition & 1 deletion crates/egui-wgpu/src/setup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ impl WgpuSetup {
#[cfg(target_arch = "wasm32")]
if backends.contains(wgpu::Backends::BROWSER_WEBGPU) {
let is_secure_context =
wgpu::web_sys::window().map_or(false, |w| w.is_secure_context());
wgpu::web_sys::window().is_some_and(|w| w.is_secure_context());
if !is_secure_context {
log::info!(
"WebGPU is only available in secure contexts, i.e. on HTTPS and on localhost."
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/collapsing_header.rs
Original file line number Diff line number Diff line change
Expand Up @@ -283,7 +283,7 @@ pub struct HeaderResponse<'ui, HeaderRet> {
header_response: InnerResponse<HeaderRet>,
}

impl<'ui, HeaderRet> HeaderResponse<'ui, HeaderRet> {
impl<HeaderRet> HeaderResponse<'_, HeaderRet> {
pub fn is_open(&self) -> bool {
self.state.is_open()
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/scroll_area.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1183,7 +1183,7 @@ impl Prepared {
&& ui.input(|i| {
i.pointer
.latest_pos()
.map_or(false, |p| handle_rect.contains(p))
.is_some_and(|p| handle_rect.contains(p))
});
let visuals = ui.visuals();
if response.is_pointer_button_down_on() {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/containers/window.rs
Original file line number Diff line number Diff line change
Expand Up @@ -415,7 +415,7 @@ impl<'open> Window<'open> {
}
}

impl<'open> Window<'open> {
impl Window<'_> {
/// Returns `None` if the window is not open (if [`Window::open`] was called with `&mut false`).
/// Returns `Some(InnerResponse { inner: None })` if the window is collapsed.
#[inline]
Expand Down
12 changes: 6 additions & 6 deletions crates/egui/src/context.rs
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,14 @@ impl ContextImpl {
fn requested_immediate_repaint_prev_pass(&self, viewport_id: &ViewportId) -> bool {
self.viewports
.get(viewport_id)
.map_or(false, |v| v.repaint.requested_immediate_repaint_prev_pass())
.is_some_and(|v| v.repaint.requested_immediate_repaint_prev_pass())
}

#[must_use]
fn has_requested_repaint(&self, viewport_id: &ViewportId) -> bool {
self.viewports.get(viewport_id).map_or(false, |v| {
0 < v.repaint.outstanding || v.repaint.repaint_delay < Duration::MAX
})
self.viewports
.get(viewport_id)
.is_some_and(|v| 0 < v.repaint.outstanding || v.repaint.repaint_delay < Duration::MAX)
}
}

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

/// Do all interaction for an existing widget, without (re-)registering it.
Expand Down Expand Up @@ -2619,7 +2619,7 @@ impl Context {
pub fn is_context_menu_open(&self) -> bool {
self.data(|d| {
d.get_temp::<crate::menu::BarState>(menu::CONTEXT_MENU_ID_STR.into())
.map_or(false, |state| state.has_root())
.is_some_and(|state| state.has_root())
})
}
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/data/input.rs
Original file line number Diff line number Diff line change
Expand Up @@ -986,7 +986,7 @@ impl ModifierNames<'static> {
};
}

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

Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/data/user_data.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ impl<'de> serde::Deserialize<'de> for UserData {
{
struct UserDataVisitor;

impl<'de> serde::de::Visitor<'de> for UserDataVisitor {
impl serde::de::Visitor<'_> for UserDataVisitor {
type Value = UserData;

fn expecting(&self, formatter: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/drag_and_drop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,7 @@ impl DragAndDrop {
pub fn has_any_payload(ctx: &Context) -> bool {
ctx.data(|data| {
let state = data.get_temp::<Self>(Id::NULL);
state.map_or(false, |state| state.payload.is_some())
state.is_some_and(|state| state.payload.is_some())
})
}
}
2 changes: 1 addition & 1 deletion crates/egui/src/input_state/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -1304,7 +1304,7 @@ impl PointerState {
self.started_decidedly_dragging
&& !self.has_moved_too_much_for_a_click
&& self.button_down(PointerButton::Primary)
&& self.press_start_time.map_or(false, |press_start_time| {
&& self.press_start_time.is_some_and(|press_start_time| {
self.time - press_start_time > self.input_options.max_click_duration
})
}
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/menu.rs
Original file line number Diff line number Diff line change
Expand Up @@ -679,7 +679,7 @@ impl MenuState {
|| self
.sub_menu
.as_ref()
.map_or(false, |(_, sub)| sub.read().area_contains(pos))
.is_some_and(|(_, sub)| sub.read().area_contains(pos))
}

fn next_entry_index(&mut self) -> usize {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/response.rs
Original file line number Diff line number Diff line change
Expand Up @@ -618,7 +618,7 @@ impl Response {
let any_open_popups = self.ctx.prev_pass_state(|fs| {
fs.layers
.get(&self.layer_id)
.map_or(false, |layer| !layer.open_popups.is_empty())
.is_some_and(|layer| !layer.open_popups.is_empty())
});
if any_open_popups {
// Hide tooltips if the user opens a popup (menu, combo-box, etc) in the same layer.
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/text_selection/label_text_selection.rs
Original file line number Diff line number Diff line change
Expand Up @@ -263,7 +263,7 @@ impl LabelSelectionState {
let new_text_starts_with_space_or_punctuation = new_text
.chars()
.next()
.map_or(false, |c| c.is_whitespace() || c.is_ascii_punctuation());
.is_some_and(|c| c.is_whitespace() || c.is_ascii_punctuation());

if existing_ends_with_space == Some(false) && !new_text_starts_with_space_or_punctuation
{
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/ui_stack.rs
Original file line number Diff line number Diff line change
Expand Up @@ -229,13 +229,13 @@ impl UiStack {
/// Is this [`crate::Ui`] a panel?
#[inline]
pub fn is_panel_ui(&self) -> bool {
self.kind().map_or(false, |kind| kind.is_panel())
self.kind().is_some_and(|kind| kind.is_panel())
}

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

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

impl<'a> FusedIterator for UiStackIterator<'a> {}
impl FusedIterator for UiStackIterator<'_> {}
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/checkbox.rs
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ impl<'a> Checkbox<'a> {
}
}

impl<'a> Widget for Checkbox<'a> {
impl Widget for Checkbox<'_> {
fn ui(self, ui: &mut Ui) -> Response {
let Checkbox {
checked,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/drag_value.rs
Original file line number Diff line number Diff line change
Expand Up @@ -426,7 +426,7 @@ impl<'a> DragValue<'a> {
}
}

impl<'a> Widget for DragValue<'a> {
impl Widget for DragValue<'_> {
fn ui(self, ui: &mut Ui) -> Response {
let Self {
mut get_set_value,
Expand Down
6 changes: 3 additions & 3 deletions crates/egui/src/widgets/image.rs
Original file line number Diff line number Diff line change
Expand Up @@ -372,7 +372,7 @@ impl<'a> Image<'a> {
}
}

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

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

impl<'a> ImageSource<'a> {
impl ImageSource<'_> {
/// Size of the texture, if known.
#[inline]
pub fn texture_size(&self) -> Option<Vec2> {
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/image_button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ impl<'a> ImageButton<'a> {
}
}

impl<'a> Widget for ImageButton<'a> {
impl Widget for ImageButton<'_> {
fn ui(self, ui: &mut Ui) -> Response {
let padding = if self.frame {
// so we can see that it is a button:
Expand Down
2 changes: 1 addition & 1 deletion crates/egui/src/widgets/label.rs
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,7 @@ impl Widget for Label {
// Interactive = the uses asked to sense interaction.
// We DON'T want to have the color respond just because the text is selectable;
// the cursor is enough to communicate that.
let interactive = self.sense.map_or(false, |sense| sense != Sense::hover());
let interactive = self.sense.is_some_and(|sense| sense != Sense::hover());

let selectable = self.selectable;

Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/widgets/slider.rs
Original file line number Diff line number Diff line change
Expand Up @@ -643,7 +643,7 @@ impl<'a> Slider<'a> {
}
}

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

impl<'a> Widget for Slider<'a> {
impl Widget for Slider<'_> {
fn ui(mut self, ui: &mut Ui) -> Response {
let inner_response = match self.orientation {
SliderOrientation::Horizontal => ui.horizontal(|ui| self.add_contents(ui)),
Expand Down
8 changes: 4 additions & 4 deletions crates/egui/src/widgets/text_edit/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -87,11 +87,11 @@ pub struct TextEdit<'t> {
background_color: Option<Color32>,
}

impl<'t> WidgetWithState for TextEdit<'t> {
impl WidgetWithState for TextEdit<'_> {
type State = TextEditState;
}

impl<'t> TextEdit<'t> {
impl TextEdit<'_> {
pub fn load_state(ctx: &Context, id: Id) -> Option<TextEditState> {
TextEditState::load(ctx, id)
}
Expand Down Expand Up @@ -393,13 +393,13 @@ impl<'t> TextEdit<'t> {

// ----------------------------------------------------------------------------

impl<'t> Widget for TextEdit<'t> {
impl Widget for TextEdit<'_> {
fn ui(self, ui: &mut Ui) -> Response {
self.show(ui).response
}
}

impl<'t> TextEdit<'t> {
impl TextEdit<'_> {
/// Show the [`TextEdit`], returning a rich [`TextEditOutput`].
///
/// ```
Expand Down
4 changes: 2 additions & 2 deletions crates/egui/src/widgets/text_edit/text_buffer.rs
Original file line number Diff line number Diff line change
Expand Up @@ -228,7 +228,7 @@ impl TextBuffer for String {
}
}

impl<'a> TextBuffer for Cow<'a, str> {
impl TextBuffer for Cow<'_, str> {
fn is_mutable(&self) -> bool {
true
}
Expand Down Expand Up @@ -259,7 +259,7 @@ impl<'a> TextBuffer for Cow<'a, str> {
}

/// Immutable view of a `&str`!
impl<'a> TextBuffer for &'a str {
impl TextBuffer for &str {
fn is_mutable(&self) -> bool {
false
}
Expand Down
4 changes: 1 addition & 3 deletions crates/egui_demo_lib/src/demo/text_edit.rs
Original file line number Diff line number Diff line change
Expand Up @@ -58,9 +58,7 @@ impl crate::View for TextEditDemo {
}
});

let anything_selected = output
.cursor_range
.map_or(false, |cursor| !cursor.is_empty());
let anything_selected = output.cursor_range.is_some_and(|cursor| !cursor.is_empty());

ui.add_enabled(
anything_selected,
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/datepicker/button.rs
Original file line number Diff line number Diff line change
Expand Up @@ -103,7 +103,7 @@ impl<'a> DatePickerButton<'a> {
}
}

impl<'a> Widget for DatePickerButton<'a> {
impl Widget for DatePickerButton<'_> {
fn ui(self, ui: &mut Ui) -> egui::Response {
let id = ui.make_persistent_id(self.id_salt);
let mut button_state = ui
Expand Down
2 changes: 1 addition & 1 deletion crates/egui_extras/src/datepicker/popup.rs
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ pub(crate) struct DatePickerPopup<'a> {
pub highlight_weekends: bool,
}

impl<'a> DatePickerPopup<'a> {
impl DatePickerPopup<'_> {
/// Returns `true` if user pressed `Save` button.
pub fn draw(&mut self, ui: &mut Ui) -> bool {
let id = ui.make_persistent_id("date_picker");
Expand Down
4 changes: 2 additions & 2 deletions crates/egui_extras/src/strip.rs
Original file line number Diff line number Diff line change
Expand Up @@ -166,7 +166,7 @@ pub struct Strip<'a, 'b> {
size_index: usize,
}

impl<'a, 'b> Strip<'a, 'b> {
impl Strip<'_, '_> {
#[cfg_attr(debug_assertions, track_caller)]
fn next_cell_size(&mut self) -> (CellSize, CellSize) {
let size = if let Some(size) = self.sizes.get(self.size_index) {
Expand Down Expand Up @@ -219,7 +219,7 @@ impl<'a, 'b> Strip<'a, 'b> {
}
}

impl<'a, 'b> Drop for Strip<'a, 'b> {
impl Drop for Strip<'_, '_> {
fn drop(&mut self) {
while self.size_index < self.sizes.len() {
self.empty();
Expand Down
Loading

0 comments on commit 7af0d5d

Please sign in to comment.