1
0
mirror of https://github.com/emilk/egui.git synced 2026-08-31 13:50:04 -04:00

Update to Rust 1.65 (#2314)

* Update to Rust 1.65

Because then you can use dynamic linking on Linux

* Fix a bunch of clippy lints

* Update changelogs

* More clippy fixes
This commit is contained in:
Emil Ernerfeldt
2022-11-16 19:08:03 +01:00
committed by GitHub
parent f7019926dc
commit eca5e6a4d2
48 changed files with 195 additions and 187 deletions

View File

@@ -4,7 +4,7 @@ version = "0.19.0"
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
description = "An easy-to-use immediate mode GUI that runs on both web and native"
edition = "2021"
rust-version = "1.62"
rust-version = "1.65"
homepage = "https://github.com/emilk/egui"
license = "MIT OR Apache-2.0"
readme = "../../README.md"

View File

@@ -293,7 +293,7 @@ impl Focus {
self.id_next_frame = self.last_interested; // frame-delay so gained_focus works
self.pressed_shift_tab = false;
}
} else if self.pressed_tab && self.id == None && !self.give_to_next {
} else if self.pressed_tab && self.id.is_none() && !self.give_to_next {
// nothing has focus and the user pressed tab - give focus to the first widgets that wants it:
self.id = Some(id);
self.pressed_tab = false;

View File

@@ -443,7 +443,7 @@ impl SubMenuButton {
let (rect, response) = ui.allocate_at_least(desired_size, sense);
response.widget_info(|| {
crate::WidgetInfo::labeled(crate::WidgetType::Button, &text_galley.text())
crate::WidgetInfo::labeled(crate::WidgetType::Button, text_galley.text())
});
if ui.is_rect_visible(rect) {
@@ -491,7 +491,7 @@ impl SubMenu {
add_contents: impl FnOnce(&mut Ui) -> R,
) -> InnerResponse<Option<R>> {
let sub_id = ui.id().with(self.button.index);
let button = self.button.show(ui, &*self.parent_state.read(), sub_id);
let button = self.button.show(ui, &self.parent_state.read(), sub_id);
self.parent_state
.write()
.submenu_button_interaction(ui, sub_id, &button);

View File

@@ -464,7 +464,7 @@ impl<'a> Widget for DragValue<'a> {
// Since we round the value being dragged, we need to store the full precision value in memory:
let stored_value = (drag_state.last_dragged_id == Some(response.id))
.then(|| drag_state.last_dragged_value)
.then_some(drag_state.last_dragged_value)
.flatten();
let stored_value = stored_value.unwrap_or(value);
let stored_value = stored_value + delta_value;

View File

@@ -110,7 +110,7 @@ impl Label {
if let Some(first_section) = text_job.job.sections.first_mut() {
first_section.leading_space = first_row_indentation;
}
let text_galley = text_job.into_galley(&*ui.fonts());
let text_galley = text_job.into_galley(&ui.fonts());
let pos = pos2(ui.max_rect().left(), ui.cursor().top());
assert!(
@@ -143,7 +143,7 @@ impl Label {
text_job.job.justify = ui.layout().horizontal_justify();
};
let text_galley = text_job.into_galley(&*ui.fonts());
let text_galley = text_job.into_galley(&ui.fonts());
let (rect, response) = ui.allocate_exact_size(text_galley.size(), self.sense);
let pos = match text_galley.galley.job.halign {
Align::LEFT => rect.left_top(),

View File

@@ -406,7 +406,7 @@ impl Line {
/// a horizontal line at the given y-coordinate.
fn y_intersection(p1: &Pos2, p2: &Pos2, y: f32) -> Option<f32> {
((p1.y > y && p2.y < y) || (p1.y < y && p2.y > y))
.then(|| ((y * (p1.x - p2.x)) - (p1.x * p2.y - p1.y * p2.x)) / (p1.y - p2.y))
.then_some(((y * (p1.x - p2.x)) - (p1.x * p2.y - p1.y * p2.x)) / (p1.y - p2.y))
}
impl PlotItem for Line {
@@ -844,7 +844,7 @@ impl PlotItem for Points {
let default_stroke = Stroke::new(stroke_size, *color);
let mut stem_stroke = default_stroke;
let stroke = (!filled)
.then(|| default_stroke)
.then_some(default_stroke)
.unwrap_or_else(Stroke::none);
let fill = filled.then(|| *color).unwrap_or_default();
@@ -1644,7 +1644,7 @@ fn add_rulers_and_text(
let corner_value = elem.corner_value();
shapes.push(Shape::text(
&*plot.ui.fonts(),
&plot.ui.fonts(),
plot.transform.position_from_point(&corner_value) + vec2(3.0, -2.0),
Align2::LEFT_BOTTOM,
text,
@@ -1701,7 +1701,7 @@ pub(super) fn rulers_at_value(
let font_id = TextStyle::Body.resolve(plot.ui.style());
shapes.push(Shape::text(
&*plot.ui.fonts(),
&plot.ui.fonts(),
pointer + vec2(3.0, -2.0),
Align2::LEFT_BOTTOM,
text,

View File

@@ -299,7 +299,7 @@ impl PlotPoints {
) -> Option<RangeInclusive<f64>> {
let start = range1.start().max(*range2.start());
let end = range1.end().min(*range2.end());
(start < end).then(|| start..=end)
(start < end).then_some(start..=end)
}
pub(super) fn bounds(&self) -> PlotBounds {

View File

@@ -189,7 +189,7 @@ impl LegendWidget {
LegendEntry::new(color, checked)
});
});
(!entries.is_empty()).then(|| Self {
(!entries.is_empty()).then_some(Self {
rect,
entries,
config,

View File

@@ -490,7 +490,7 @@ impl<'t> TextEdit<'t> {
if response.hovered() && ui.input().pointer.any_pressed() {
ui.memory().request_focus(id);
if ui.input().modifiers.shift {
if let Some(mut cursor_range) = state.cursor_range(&*galley) {
if let Some(mut cursor_range) = state.cursor_range(&galley) {
cursor_range.primary = cursor_at_pointer;
state.set_cursor_range(Some(cursor_range));
} else {
@@ -502,7 +502,7 @@ impl<'t> TextEdit<'t> {
} else if ui.input().pointer.any_down() && response.is_pointer_button_down_on()
{
// drag to select text:
if let Some(mut cursor_range) = state.cursor_range(&*galley) {
if let Some(mut cursor_range) = state.cursor_range(&galley) {
cursor_range.primary = cursor_at_pointer;
state.set_cursor_range(Some(cursor_range));
}
@@ -516,7 +516,7 @@ impl<'t> TextEdit<'t> {
}
let mut cursor_range = None;
let prev_cursor_range = state.cursor_range(&*galley);
let prev_cursor_range = state.cursor_range(&galley);
if ui.memory().has_focus(id) && interactive {
ui.memory().lock_focus(id, lock_focus);
@@ -595,7 +595,7 @@ impl<'t> TextEdit<'t> {
}
if ui.memory().has_focus(id) {
if let Some(cursor_range) = state.cursor_range(&*galley) {
if let Some(cursor_range) = state.cursor_range(&galley) {
// We paint the cursor on top of the text, in case
// the text galley has backgrounds (as e.g. `code` snippets in markup do).
paint_cursor_selection(ui, &painter, text_draw_pos, &galley, &cursor_range);
@@ -703,7 +703,7 @@ fn events(
password: bool,
default_cursor_range: CursorRange,
) -> (bool, CursorRange) {
let mut cursor_range = state.cursor_range(&*galley).unwrap_or(default_cursor_range);
let mut cursor_range = state.cursor_range(galley).unwrap_or(default_cursor_range);
// We feed state to the undoer both before and after handling input
// so that the undoer creates automatic saves even when there are no events for a while.