mirror of
https://github.com/emilk/egui.git
synced 2026-09-02 06:40:06 -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,6 +1,6 @@
|
||||
#![expect(clippy::many_single_char_names)]
|
||||
|
||||
use std::ops::Range;
|
||||
use core::ops::Range;
|
||||
|
||||
use crate::{Color32, PathShape, PathStroke, Shape};
|
||||
use emath::{Pos2, Rect, RectTransform, fast_midpoint};
|
||||
@@ -256,8 +256,8 @@ impl CubicBezierShape {
|
||||
let theta = (-q / (2.0 * r)).acos() / 3.0;
|
||||
|
||||
let t1 = 2.0 * r.cbrt() * theta.cos() + h;
|
||||
let t2 = 2.0 * r.cbrt() * (theta + 120.0 * std::f32::consts::PI / 180.0).cos() + h;
|
||||
let t3 = 2.0 * r.cbrt() * (theta + 240.0 * std::f32::consts::PI / 180.0).cos() + h;
|
||||
let t2 = 2.0 * r.cbrt() * (theta + 120.0 * core::f32::consts::PI / 180.0).cos() + h;
|
||||
let t3 = 2.0 * r.cbrt() * (theta + 240.0 * core::f32::consts::PI / 180.0).cos() + h;
|
||||
|
||||
if t1 > epsilon && t1 < 1.0 - epsilon {
|
||||
return Some(t1);
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
use std::{any::Any, sync::Arc};
|
||||
use core::any::Any;
|
||||
use std::sync::Arc;
|
||||
|
||||
use crate::*;
|
||||
|
||||
@@ -32,7 +33,7 @@ fn test_viewport_rounding() {
|
||||
let left = Rect::from_min_max(pos2(0.0, 0.0), pos2(100.0, 100.0)).with_max_x(x);
|
||||
let right = Rect::from_min_max(pos2(0.0, 0.0), pos2(100.0, 100.0)).with_min_x(x);
|
||||
|
||||
for pixels_per_point in [0.618, 1.0, std::f32::consts::PI] {
|
||||
for pixels_per_point in [0.618, 1.0, core::f32::consts::PI] {
|
||||
let left = ViewportInPixels::from_points(&left, pixels_per_point, [100, 100]);
|
||||
let right = ViewportInPixels::from_points(&right, pixels_per_point, [100, 100]);
|
||||
assert_eq!(left.left_px + left.width_px, right.left_px);
|
||||
@@ -81,15 +82,15 @@ pub struct PaintCallback {
|
||||
pub callback: Arc<dyn Any + Send + Sync>,
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for PaintCallback {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl core::fmt::Debug for PaintCallback {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
f.debug_struct("CustomShape")
|
||||
.field("rect", &self.rect)
|
||||
.finish_non_exhaustive()
|
||||
}
|
||||
}
|
||||
|
||||
impl std::cmp::PartialEq for PaintCallback {
|
||||
impl core::cmp::PartialEq for PaintCallback {
|
||||
fn eq(&self, other: &Self) -> bool {
|
||||
self.rect.eq(&other.rect) && Arc::ptr_eq(&self.callback, &other.callback)
|
||||
}
|
||||
|
||||
@@ -62,12 +62,12 @@ pub struct RectShape {
|
||||
#[test]
|
||||
fn rect_shape_size() {
|
||||
assert_eq!(
|
||||
std::mem::size_of::<RectShape>(),
|
||||
core::mem::size_of::<RectShape>(),
|
||||
56,
|
||||
"RectShape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
|
||||
);
|
||||
assert!(
|
||||
std::mem::size_of::<RectShape>() <= 64,
|
||||
core::mem::size_of::<RectShape>() <= 64,
|
||||
"RectShape is getting way too big!"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -73,12 +73,12 @@ pub enum Shape {
|
||||
#[test]
|
||||
fn shape_size() {
|
||||
assert_eq!(
|
||||
std::mem::size_of::<Shape>(),
|
||||
core::mem::size_of::<Shape>(),
|
||||
64,
|
||||
"Shape changed size! If it shrank - good! Update this test. If it grew - bad! Try to find a way to avoid it."
|
||||
);
|
||||
assert!(
|
||||
std::mem::size_of::<Shape>() <= 64,
|
||||
core::mem::size_of::<Shape>() <= 64,
|
||||
"Shape is getting way too big!"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -201,7 +201,7 @@ mod tests {
|
||||
|
||||
// 90 degree rotation
|
||||
if let Shape::Text(ts) = &mut t {
|
||||
ts.angle = std::f32::consts::PI / 2.0;
|
||||
ts.angle = core::f32::consts::PI / 2.0;
|
||||
}
|
||||
|
||||
let size_rot = t.visual_bounding_rect().size();
|
||||
|
||||
Reference in New Issue
Block a user