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

More newlines for improved readability (#1880)

* Add blank lines above all `fn`, `impl`, `struct`, etc
* Even newlines between docstringed struct and enum fields
* Improve some documentation
This commit is contained in:
Emil Ernerfeldt
2022-08-02 17:26:33 +02:00
committed by GitHub
parent 5d8ef5326b
commit 10788ccc92
56 changed files with 306 additions and 12 deletions

View File

@@ -19,10 +19,13 @@ pub enum Align {
impl Align {
/// Convenience for [`Self::Min`]
pub const LEFT: Self = Self::Min;
/// Convenience for [`Self::Max`]
pub const RIGHT: Self = Self::Max;
/// Convenience for [`Self::Min`]
pub const TOP: Self = Self::Min;
/// Convenience for [`Self::Max`]
pub const BOTTOM: Self = Self::Max;

View File

@@ -51,12 +51,14 @@ pub use {
pub trait One {
fn one() -> Self;
}
impl One for f32 {
#[inline(always)]
fn one() -> Self {
1.0
}
}
impl One for f64 {
#[inline(always)]
fn one() -> Self {
@@ -78,6 +80,7 @@ pub trait Real:
}
impl Real for f32 {}
impl Real for f64 {}
// ----------------------------------------------------------------------------
@@ -251,6 +254,7 @@ macro_rules! impl_num_ext {
fn at_least(self, lower_limit: Self) -> Self {
self.max(lower_limit)
}
#[inline(always)]
fn at_most(self, upper_limit: Self) -> Self {
self.min(upper_limit)

View File

@@ -415,11 +415,13 @@ impl Rect {
pub fn left(&self) -> f32 {
self.min.x
}
/// `min.x`
#[inline(always)]
pub fn left_mut(&mut self) -> &mut f32 {
&mut self.min.x
}
/// `min.x`
#[inline(always)]
pub fn set_left(&mut self, x: f32) {
@@ -431,11 +433,13 @@ impl Rect {
pub fn right(&self) -> f32 {
self.max.x
}
/// `max.x`
#[inline(always)]
pub fn right_mut(&mut self) -> &mut f32 {
&mut self.max.x
}
/// `max.x`
#[inline(always)]
pub fn set_right(&mut self, x: f32) {
@@ -447,11 +451,13 @@ impl Rect {
pub fn top(&self) -> f32 {
self.min.y
}
/// `min.y`
#[inline(always)]
pub fn top_mut(&mut self) -> &mut f32 {
&mut self.min.y
}
/// `min.y`
#[inline(always)]
pub fn set_top(&mut self, y: f32) {
@@ -463,11 +469,13 @@ impl Rect {
pub fn bottom(&self) -> f32 {
self.max.y
}
/// `max.y`
#[inline(always)]
pub fn bottom_mut(&mut self) -> &mut f32 {
&mut self.max.y
}
/// `max.y`
#[inline(always)]
pub fn set_bottom(&mut self, y: f32) {

View File

@@ -67,6 +67,7 @@ impl RectTransform {
/// Transforms the position.
impl std::ops::Mul<Pos2> for RectTransform {
type Output = Pos2;
fn mul(self, pos: Pos2) -> Pos2 {
self.transform_pos(pos)
}
@@ -75,6 +76,7 @@ impl std::ops::Mul<Pos2> for RectTransform {
/// Transforms the position.
impl std::ops::Mul<Pos2> for &RectTransform {
type Output = Pos2;
fn mul(self, pos: Pos2) -> Pos2 {
self.transform_pos(pos)
}

View File

@@ -20,6 +20,7 @@ use super::Vec2;
pub struct Rot2 {
/// angle.sin()
s: f32,
/// angle.cos()
c: f32,
}
@@ -93,6 +94,7 @@ impl std::fmt::Debug for Rot2 {
impl std::ops::Mul<Rot2> for Rot2 {
type Output = Rot2;
fn mul(self, r: Rot2) -> Rot2 {
/*
|lc -ls| * |rc -rs|
@@ -108,6 +110,7 @@ impl std::ops::Mul<Rot2> for Rot2 {
/// Rotates (and maybe scales) the vector.
impl std::ops::Mul<Vec2> for Rot2 {
type Output = Vec2;
fn mul(self, v: Vec2) -> Vec2 {
Vec2 {
x: self.c * v.x - self.s * v.y,
@@ -119,6 +122,7 @@ impl std::ops::Mul<Vec2> for Rot2 {
/// Scales the rotor.
impl std::ops::Mul<Rot2> for f32 {
type Output = Rot2;
fn mul(self, r: Rot2) -> Rot2 {
Rot2 {
c: self * r.c,
@@ -130,6 +134,7 @@ impl std::ops::Mul<Rot2> for f32 {
/// Scales the rotor.
impl std::ops::Mul<f32> for Rot2 {
type Output = Rot2;
fn mul(self, r: f32) -> Rot2 {
Rot2 {
c: self.c * r,
@@ -141,6 +146,7 @@ impl std::ops::Mul<f32> for Rot2 {
/// Scales the rotor.
impl std::ops::Div<f32> for Rot2 {
type Output = Rot2;
fn div(self, r: f32) -> Rot2 {
Rot2 {
c: self.c / r,

View File

@@ -13,6 +13,7 @@ use std::ops::{Add, AddAssign, Div, Mul, MulAssign, Neg, Sub, SubAssign};
pub struct Vec2 {
/// Rightwards. Width.
pub x: f32,
/// Downwards. Height.
pub y: f32,
}