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:
@@ -92,8 +92,8 @@ impl Rot2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::fmt::Debug for Rot2 {
|
||||
fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
|
||||
impl core::fmt::Debug for Rot2 {
|
||||
fn fmt(&self, f: &mut core::fmt::Formatter<'_>) -> core::fmt::Result {
|
||||
if let Some(precision) = f.precision() {
|
||||
write!(
|
||||
f,
|
||||
@@ -113,7 +113,7 @@ impl std::fmt::Debug for Rot2 {
|
||||
}
|
||||
}
|
||||
|
||||
impl std::ops::Mul<Self> for Rot2 {
|
||||
impl core::ops::Mul<Self> for Rot2 {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
@@ -130,7 +130,7 @@ impl std::ops::Mul<Self> for Rot2 {
|
||||
}
|
||||
|
||||
/// Rotates (and maybe scales) the vector.
|
||||
impl std::ops::Mul<Vec2> for Rot2 {
|
||||
impl core::ops::Mul<Vec2> for Rot2 {
|
||||
type Output = Vec2;
|
||||
|
||||
#[inline]
|
||||
@@ -143,7 +143,7 @@ impl std::ops::Mul<Vec2> for Rot2 {
|
||||
}
|
||||
|
||||
/// Scales the rotor.
|
||||
impl std::ops::Mul<Rot2> for f32 {
|
||||
impl core::ops::Mul<Rot2> for f32 {
|
||||
type Output = Rot2;
|
||||
|
||||
#[inline]
|
||||
@@ -156,7 +156,7 @@ impl std::ops::Mul<Rot2> for f32 {
|
||||
}
|
||||
|
||||
/// Scales the rotor.
|
||||
impl std::ops::Mul<f32> for Rot2 {
|
||||
impl core::ops::Mul<f32> for Rot2 {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
@@ -169,7 +169,7 @@ impl std::ops::Mul<f32> for Rot2 {
|
||||
}
|
||||
|
||||
/// Scales the rotor.
|
||||
impl std::ops::Div<f32> for Rot2 {
|
||||
impl core::ops::Div<f32> for Rot2 {
|
||||
type Output = Self;
|
||||
|
||||
#[inline]
|
||||
@@ -189,7 +189,7 @@ mod test {
|
||||
#[test]
|
||||
fn test_rotation2() {
|
||||
{
|
||||
let angle = std::f32::consts::TAU / 6.0;
|
||||
let angle = core::f32::consts::TAU / 6.0;
|
||||
let rot = Rot2::from_angle(angle);
|
||||
assert!((rot.angle() - angle).abs() < 1e-5);
|
||||
assert!((rot * rot.inverse()).angle().abs() < 1e-5);
|
||||
@@ -197,14 +197,14 @@ mod test {
|
||||
}
|
||||
|
||||
{
|
||||
let angle = std::f32::consts::TAU / 4.0;
|
||||
let angle = core::f32::consts::TAU / 4.0;
|
||||
let rot = Rot2::from_angle(angle);
|
||||
assert!(((rot * vec2(1.0, 0.0)) - vec2(0.0, 1.0)).length() < 1e-5);
|
||||
}
|
||||
|
||||
{
|
||||
// Test rotation and scaling
|
||||
let angle = std::f32::consts::TAU / 4.0;
|
||||
let angle = core::f32::consts::TAU / 4.0;
|
||||
let rot = 3.0 * Rot2::from_angle(angle);
|
||||
let rotated = rot * vec2(1.0, 0.0);
|
||||
let expected = vec2(0.0, 3.0);
|
||||
|
||||
Reference in New Issue
Block a user