mirror of
https://github.com/emilk/egui.git
synced 2026-09-03 07:10:04 -04:00
Enable the clippy::std_instead_of_core lint (#8394)
Prefer `core::` over `std::` where either work * Part of https://github.com/emilk/egui/issues/5735
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
use std::mem;
|
||||
use core::mem;
|
||||
|
||||
use accesskit::{Action, ActionRequest};
|
||||
use accesskit_consumer::{FilterResult, Node, NodeId, Tree, TreeChangeHandler};
|
||||
@@ -168,7 +168,7 @@ impl AccessibilityInspectorPlugin {
|
||||
ui.horizontal_wrapped(|ui| {
|
||||
// Iterate through all possible actions via the `Action::n` helper.
|
||||
let mut current_action = 0;
|
||||
let all_actions = std::iter::from_fn(|| {
|
||||
let all_actions = core::iter::from_fn(|| {
|
||||
let action = Action::n(current_action);
|
||||
current_action += 1;
|
||||
action
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
#![expect(clippy::unwrap_used)] // TODO(emilk): avoid unwraps
|
||||
|
||||
use std::num::NonZeroU64;
|
||||
use core::num::NonZeroU64;
|
||||
|
||||
use eframe::{
|
||||
egui_wgpu::wgpu::util::DeviceExt as _,
|
||||
|
||||
@@ -1,10 +1,10 @@
|
||||
use core::f32::consts::TAU;
|
||||
use egui::{
|
||||
Color32, Painter, Pos2, Rect, Shape, Stroke, Ui, Vec2,
|
||||
containers::{CollapsingHeader, Frame},
|
||||
emath, pos2,
|
||||
widgets::Slider,
|
||||
};
|
||||
use std::f32::consts::TAU;
|
||||
|
||||
#[derive(PartialEq)]
|
||||
#[cfg_attr(feature = "serde", derive(serde::Deserialize, serde::Serialize))]
|
||||
@@ -202,7 +202,7 @@ impl FractalClock {
|
||||
}
|
||||
}
|
||||
|
||||
std::mem::swap(&mut nodes, &mut new_nodes);
|
||||
core::mem::swap(&mut nodes, &mut new_nodes);
|
||||
}
|
||||
self.line_count = shapes.len();
|
||||
painter.extend(shapes);
|
||||
|
||||
@@ -160,9 +160,9 @@ impl BackendPanel {
|
||||
{
|
||||
log::info!("Waiting 2s before requesting repaint…");
|
||||
let ctx = ui.ctx().clone();
|
||||
call_after_delay(std::time::Duration::from_secs(2), move || {
|
||||
call_after_delay(core::time::Duration::from_secs(2), move || {
|
||||
log::info!("Request a repaint in 3s…");
|
||||
ctx.request_repaint_after(std::time::Duration::from_secs(3));
|
||||
ctx.request_repaint_after(core::time::Duration::from_secs(3));
|
||||
});
|
||||
}
|
||||
|
||||
@@ -525,7 +525,7 @@ impl EguiWindows {
|
||||
// ----------------------------------------------------------------------------
|
||||
|
||||
#[cfg(not(target_arch = "wasm32"))]
|
||||
fn call_after_delay(delay: std::time::Duration, f: impl FnOnce() + Send + 'static) {
|
||||
fn call_after_delay(delay: core::time::Duration, f: impl FnOnce() + Send + 'static) {
|
||||
std::thread::Builder::new()
|
||||
.name("call_after_delay".to_owned())
|
||||
.spawn(move || {
|
||||
@@ -536,7 +536,7 @@ fn call_after_delay(delay: std::time::Duration, f: impl FnOnce() + Send + 'stati
|
||||
}
|
||||
|
||||
#[cfg(target_arch = "wasm32")]
|
||||
fn call_after_delay(delay: std::time::Duration, f: impl FnOnce() + Send + 'static) {
|
||||
fn call_after_delay(delay: core::time::Duration, f: impl FnOnce() + Send + 'static) {
|
||||
#![expect(clippy::unwrap_used)]
|
||||
|
||||
use wasm_bindgen::prelude::*;
|
||||
|
||||
@@ -38,7 +38,7 @@ fn main() {
|
||||
});
|
||||
for loud_crate in ["naga", "wgpu_core", "wgpu_hal"] {
|
||||
if !rust_log.contains(&format!("{loud_crate}=")) {
|
||||
use std::fmt::Write as _;
|
||||
use core::fmt::Write as _;
|
||||
write!(rust_log, ",{loud_crate}=warn").ok();
|
||||
}
|
||||
}
|
||||
@@ -103,7 +103,7 @@ fn start_puffin_server() {
|
||||
// We can store the server if we want, but in this case we just want
|
||||
// it to keep running. Dropping it closes the server, so let's not drop it!
|
||||
#[expect(clippy::mem_forget)]
|
||||
std::mem::forget(puffin_server);
|
||||
core::mem::forget(puffin_server);
|
||||
}
|
||||
Err(err) => {
|
||||
log::error!("Failed to start puffin server: {err}");
|
||||
|
||||
@@ -127,8 +127,8 @@ impl Anchor {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Display for Anchor {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl core::fmt::Display for Anchor {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
let mut name = format!("{self:?}");
|
||||
name.make_ascii_lowercase();
|
||||
f.write_str(&name)
|
||||
@@ -473,8 +473,8 @@ impl WrapApp {
|
||||
}
|
||||
|
||||
fn ui_file_drag_and_drop(&mut self, ctx: &egui::Context) {
|
||||
use core::fmt::Write as _;
|
||||
use egui::{Align2, Color32, Id, LayerId, Order, TextStyle};
|
||||
use std::fmt::Write as _;
|
||||
|
||||
// Preview hovering files:
|
||||
if !ctx.input(|i| i.raw.hovered_files.is_empty()) {
|
||||
|
||||
Reference in New Issue
Block a user