mirror of
https://github.com/emilk/egui.git
synced 2026-08-29 21:00:03 -04:00
Update MSRV to Rust 1.70.0 (#3310)
* Update to Rust 1.70 * Fix renamed clippy lint * Use let-else more * Code cleanup * Remove derelict Safety comments * Enable more clippy lints
This commit is contained in:
@@ -7,7 +7,7 @@ authors = [
|
||||
]
|
||||
description = "Color structs and color conversion utilities"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -38,7 +38,7 @@ pub(crate) fn f32_hash<H: std::hash::Hasher>(state: &mut H, f: f32) {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
impl std::hash::Hash for Rgba {
|
||||
#[inline]
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "egui framework - write GUI apps that compiles to web and/or natively"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/eframe"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -35,7 +35,6 @@ pub fn pos_from_touch_event(
|
||||
// search for the touch we previously used for the position
|
||||
// (unfortunately, `event.touches()` is not a rust collection):
|
||||
(0..event.touches().length())
|
||||
.into_iter()
|
||||
.map(|i| event.touches().get(i).unwrap())
|
||||
.find(|touch| egui::TouchId::from(touch.identifier()) == *touch_id_for_pos)
|
||||
} else {
|
||||
|
||||
@@ -148,9 +148,7 @@ impl WebPainter for WebPainterWgpu {
|
||||
) -> Result<(), JsValue> {
|
||||
let size_in_pixels = [self.canvas.width(), self.canvas.height()];
|
||||
|
||||
let render_state = if let Some(render_state) = &self.render_state {
|
||||
render_state
|
||||
} else {
|
||||
let Some(render_state) = &self.render_state else {
|
||||
return Err(JsValue::from_str(
|
||||
"Can't paint, wgpu renderer was already disposed",
|
||||
));
|
||||
|
||||
@@ -8,7 +8,7 @@ authors = [
|
||||
"Emil Ernerfeldt <emil.ernerfeldt@gmail.com>",
|
||||
]
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/egui-wgpu"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -435,9 +435,7 @@ impl Renderer {
|
||||
}
|
||||
}
|
||||
Primitive::Callback(callback) => {
|
||||
let cbfn = if let Some(c) = callback.callback.downcast_ref::<Callback>() {
|
||||
c
|
||||
} else {
|
||||
let Some(cbfn) = callback.callback.downcast_ref::<Callback>() else {
|
||||
// We already warned in the `prepare` callback
|
||||
continue;
|
||||
};
|
||||
|
||||
@@ -175,12 +175,6 @@ impl Painter {
|
||||
/// [`set_window`](Self::set_window) may be called with `Some(window)` as soon as you have a
|
||||
/// valid [`winit::window::Window`].
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The raw Window handle associated with the given `window` must be a valid object to create a
|
||||
/// surface upon and must remain valid for the lifetime of the created surface. (The surface may
|
||||
/// be cleared by passing `None`).
|
||||
///
|
||||
/// # Errors
|
||||
/// If the provided wgpu configuration does not match an available device.
|
||||
pub async fn set_window(
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Bindings for using egui with winit"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/egui-winit"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -26,10 +26,6 @@ pub struct Clipboard {
|
||||
|
||||
impl Clipboard {
|
||||
/// Construct a new instance
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The returned `Clipboard` must not outlive the input `_display_target`.
|
||||
pub fn new(_display_target: &dyn HasRawDisplayHandle) -> Self {
|
||||
Self {
|
||||
#[cfg(all(feature = "arboard", not(target_os = "android")))]
|
||||
|
||||
@@ -84,10 +84,6 @@ pub struct State {
|
||||
|
||||
impl State {
|
||||
/// Construct a new instance
|
||||
///
|
||||
/// # Safety
|
||||
///
|
||||
/// The returned `State` must not outlive the input `display_target`.
|
||||
pub fn new(display_target: &dyn HasRawDisplayHandle) -> Self {
|
||||
let egui_input = egui::RawInput {
|
||||
focused: false, // winit will tell us when we have focus
|
||||
|
||||
@@ -137,12 +137,10 @@ fn clamp_pos_to_monitors<E>(
|
||||
let monitors = event_loop.available_monitors();
|
||||
|
||||
// default to primary monitor, in case the correct monitor was disconnected.
|
||||
let mut active_monitor = if let Some(active_monitor) = event_loop
|
||||
let Some(mut active_monitor) = event_loop
|
||||
.primary_monitor()
|
||||
.or_else(|| event_loop.available_monitors().next())
|
||||
{
|
||||
active_monitor
|
||||
} else {
|
||||
else {
|
||||
return; // no monitors 🤷
|
||||
};
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.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.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "../../README.md"
|
||||
|
||||
@@ -449,7 +449,9 @@ impl Focus {
|
||||
}
|
||||
});
|
||||
|
||||
let current_rect = *self.focus_widgets_cache.get(&focus_id).unwrap();
|
||||
let Some(current_rect) = self.focus_widgets_cache.get(&focus_id) else {
|
||||
return None;
|
||||
};
|
||||
|
||||
let mut best_score = std::f32::INFINITY;
|
||||
let mut best_id = None;
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
license = "MIT OR Apache-2.0"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
publish = false
|
||||
default-run = "egui_demo_app"
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Example library for egui"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_demo_lib"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -8,7 +8,7 @@ authors = [
|
||||
]
|
||||
description = "Extra functionality and widgets for the egui GUI library"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Bindings for using egui natively using the glium library"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glium"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Bindings for using egui natively using the glow library"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/egui_glow"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -8,7 +8,7 @@ authors = [
|
||||
]
|
||||
description = "Immediate mode plotting for the egui GUI library"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -255,9 +255,8 @@ impl AxisWidget {
|
||||
|
||||
// --- add ticks ---
|
||||
let font_id = TextStyle::Body.resolve(ui.style());
|
||||
let transform = match self.transform {
|
||||
Some(t) => t,
|
||||
None => return response,
|
||||
let Some(transform) = self.transform else {
|
||||
return response;
|
||||
};
|
||||
|
||||
for step in self.steps.iter() {
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
//! Contains items that can be added to a plot.
|
||||
#![allow(clippy::type_complexity)] // TODO(emilk): simplify some of the callback types with type aliases
|
||||
|
||||
use std::ops::RangeInclusive;
|
||||
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Minimal 2D math library for GUI work"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/emath"
|
||||
license = "MIT OR Apache-2.0"
|
||||
readme = "README.md"
|
||||
|
||||
@@ -360,9 +360,17 @@ impl Rect {
|
||||
/// Signed distance to the edge of the box.
|
||||
///
|
||||
/// Negative inside the box.
|
||||
///
|
||||
/// ```
|
||||
/// # use emath::{pos2, Rect};
|
||||
/// let rect = Rect::from_min_max(pos2(0.0, 0.0), pos2(1.0, 1.0));
|
||||
/// assert_eq!(rect.signed_distance_to_pos(pos2(0.50, 0.50)), -0.50);
|
||||
/// assert_eq!(rect.signed_distance_to_pos(pos2(0.75, 0.50)), -0.25);
|
||||
/// assert_eq!(rect.signed_distance_to_pos(pos2(1.50, 0.50)), 0.50);
|
||||
/// ```
|
||||
pub fn signed_distance_to_pos(&self, pos: Pos2) -> f32 {
|
||||
let edge_distances = (pos - self.center()).abs() - self.size() * 0.5;
|
||||
let inside_dist = edge_distances.x.max(edge_distances.y).min(0.0);
|
||||
let inside_dist = edge_distances.max_elem().min(0.0);
|
||||
let outside_dist = edge_distances.max(Vec2::ZERO).length();
|
||||
inside_dist + outside_dist
|
||||
}
|
||||
|
||||
@@ -4,7 +4,7 @@ version = "0.22.0"
|
||||
authors = ["Emil Ernerfeldt <emil.ernerfeldt@gmail.com>"]
|
||||
description = "Minimal 2D graphics library for GUI work"
|
||||
edition = "2021"
|
||||
rust-version = "1.67"
|
||||
rust-version = "1.70"
|
||||
homepage = "https://github.com/emilk/egui/tree/master/crates/epaint"
|
||||
license = "(MIT OR Apache-2.0) AND OFL-1.1 AND LicenseRef-UFL-1.0" # OFL and UFL used by default_fonts. See https://github.com/emilk/egui/issues/2321
|
||||
readme = "README.md"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::derive_hash_xor_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
|
||||
#![allow(clippy::derived_hash_with_manual_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
|
||||
|
||||
use super::*;
|
||||
|
||||
|
||||
@@ -51,7 +51,7 @@ impl FontId {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
impl std::hash::Hash for FontId {
|
||||
#[inline(always)]
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
@@ -552,7 +552,7 @@ impl FontsAndCache {
|
||||
#[derive(Clone, Copy, Debug, PartialEq)]
|
||||
struct HashableF32(f32);
|
||||
|
||||
#[allow(clippy::derive_hash_xor_eq)]
|
||||
#[allow(clippy::derived_hash_with_manual_eq)]
|
||||
impl std::hash::Hash for HashableF32 {
|
||||
#[inline(always)]
|
||||
fn hash<H: std::hash::Hasher>(&self, state: &mut H) {
|
||||
|
||||
@@ -320,9 +320,8 @@ fn replace_last_glyph_with_overflow_character(
|
||||
job: &LayoutJob,
|
||||
row: &mut Row,
|
||||
) {
|
||||
let overflow_character = match job.wrap.overflow_character {
|
||||
Some(c) => c,
|
||||
None => return,
|
||||
let Some(overflow_character) = job.wrap.overflow_character else {
|
||||
return;
|
||||
};
|
||||
|
||||
loop {
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
#![allow(clippy::derive_hash_xor_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
|
||||
#![allow(clippy::derived_hash_with_manual_eq)] // We need to impl Hash for f32, but we don't implement Eq, which is fine
|
||||
#![allow(clippy::wrong_self_convention)] // We use `from_` to indicate conversion direction. It's non-diomatic, but makes sense in this context.
|
||||
|
||||
use std::ops::Range;
|
||||
|
||||
Reference in New Issue
Block a user