diff options
| author | Laurenz <laurmaedje@gmail.com> | 2022-11-04 09:30:44 +0100 |
|---|---|---|
| committer | Laurenz <laurmaedje@gmail.com> | 2022-11-04 11:38:09 +0100 |
| commit | eb951c008beea502042db4a3a0e8d1f8b51f6f52 (patch) | |
| tree | 9856ee4ed0222222669de10e616a580b2a60135e /src/geom | |
| parent | 33928a00dc58250e24da1dae4e5db17e7b598d70 (diff) | |
Style changes
Diffstat (limited to 'src/geom')
| -rw-r--r-- | src/geom/axes.rs | 15 | ||||
| -rw-r--r-- | src/geom/corners.rs | 16 | ||||
| -rw-r--r-- | src/geom/ellipse.rs | 6 | ||||
| -rw-r--r-- | src/geom/em.rs | 6 | ||||
| -rw-r--r-- | src/geom/length.rs | 5 | ||||
| -rw-r--r-- | src/geom/mod.rs | 54 | ||||
| -rw-r--r-- | src/geom/paint.rs | 11 | ||||
| -rw-r--r-- | src/geom/ratio.rs | 6 | ||||
| -rw-r--r-- | src/geom/rel.rs | 10 | ||||
| -rw-r--r-- | src/geom/rounded.rs | 6 |
10 files changed, 47 insertions, 88 deletions
diff --git a/src/geom/axes.rs b/src/geom/axes.rs index bfc40c2e..04023898 100644 --- a/src/geom/axes.rs +++ b/src/geom/axes.rs @@ -54,10 +54,7 @@ impl<T> Axes<T> { /// Zip two instances into an instance over a tuple. pub fn zip<U>(self, other: Axes<U>) -> Axes<(T, U)> { - Axes { - x: (self.x, other.x), - y: (self.y, other.y), - } + Axes { x: (self.x, other.x), y: (self.y, other.y) } } /// Whether a condition is true for at least one of fields. @@ -100,18 +97,12 @@ impl<T: Default> Axes<T> { impl<T: Ord> Axes<T> { /// The component-wise minimum of this and another instance. pub fn min(self, other: Self) -> Self { - Self { - x: self.x.min(other.x), - y: self.y.min(other.y), - } + Self { x: self.x.min(other.x), y: self.y.min(other.y) } } /// The component-wise minimum of this and another instance. pub fn max(self, other: Self) -> Self { - Self { - x: self.x.max(other.x), - y: self.y.max(other.y), - } + Self { x: self.x.max(other.x), y: self.y.max(other.y) } } } diff --git a/src/geom/corners.rs b/src/geom/corners.rs index 54fcd12f..d84160cc 100644 --- a/src/geom/corners.rs +++ b/src/geom/corners.rs @@ -16,12 +16,7 @@ pub struct Corners<T> { impl<T> Corners<T> { /// Create a new instance from the four components. pub const fn new(top_left: T, top_right: T, bottom_right: T, bottom_left: T) -> Self { - Self { - top_left, - top_right, - bottom_right, - bottom_left, - } + Self { top_left, top_right, bottom_right, bottom_left } } /// Create an instance with four equal components. @@ -66,13 +61,8 @@ impl<T> Corners<T> { /// An iterator over the corners, starting with the top left corner, /// clockwise. pub fn iter(&self) -> impl Iterator<Item = &T> { - [ - &self.top_left, - &self.top_right, - &self.bottom_right, - &self.bottom_left, - ] - .into_iter() + [&self.top_left, &self.top_right, &self.bottom_right, &self.bottom_left] + .into_iter() } /// Whether all sides are equal. diff --git a/src/geom/ellipse.rs b/src/geom/ellipse.rs index e734682e..ac20ffd3 100644 --- a/src/geom/ellipse.rs +++ b/src/geom/ellipse.rs @@ -18,9 +18,5 @@ pub fn ellipse(size: Size, fill: Option<Paint>, stroke: Option<Stroke>) -> Shape path.cubic_to(point(rx, my), point(mx, ry), point(z, ry)); path.cubic_to(point(-mx, ry), point(-rx, my), point(-rx, z)); - Shape { - geometry: Geometry::Path(path), - stroke, - fill, - } + Shape { geometry: Geometry::Path(path), stroke, fill } } diff --git a/src/geom/em.rs b/src/geom/em.rs index d0ad9d98..93dc80e4 100644 --- a/src/geom/em.rs +++ b/src/geom/em.rs @@ -45,7 +45,11 @@ impl Em { /// Convert to an absolute length at the given font size. pub fn at(self, font_size: Abs) -> Abs { let resolved = font_size * self.get(); - if resolved.is_finite() { resolved } else { Abs::zero() } + if resolved.is_finite() { + resolved + } else { + Abs::zero() + } } } diff --git a/src/geom/length.rs b/src/geom/length.rs index cd526f99..230ea48b 100644 --- a/src/geom/length.rs +++ b/src/geom/length.rs @@ -92,10 +92,7 @@ impl Add for Length { type Output = Self; fn add(self, rhs: Self) -> Self::Output { - Self { - abs: self.abs + rhs.abs, - em: self.em + rhs.em, - } + Self { abs: self.abs + rhs.abs, em: self.em + rhs.em } } } diff --git a/src/geom/mod.rs b/src/geom/mod.rs index c1469b26..3c7c2fc9 100644 --- a/src/geom/mod.rs +++ b/src/geom/mod.rs @@ -24,27 +24,27 @@ mod size; mod stroke; mod transform; -pub use abs::*; -pub use align::*; -pub use angle::*; -pub use axes::*; -pub use corners::*; -pub use dir::*; -pub use ellipse::*; -pub use em::*; -pub use fr::*; -pub use length::*; -pub use paint::*; -pub use path::*; -pub use point::*; -pub use ratio::*; -pub use rel::*; -pub use rounded::*; -pub use scalar::*; -pub use sides::*; -pub use size::*; -pub use stroke::*; -pub use transform::*; +pub use self::abs::*; +pub use self::align::*; +pub use self::angle::*; +pub use self::axes::*; +pub use self::corners::*; +pub use self::dir::*; +pub use self::ellipse::*; +pub use self::em::*; +pub use self::fr::*; +pub use self::length::*; +pub use self::paint::*; +pub use self::path::*; +pub use self::point::*; +pub use self::ratio::*; +pub use self::rel::*; +pub use self::rounded::*; +pub use self::scalar::*; +pub use self::sides::*; +pub use self::size::*; +pub use self::stroke::*; +pub use self::transform::*; use std::cmp::Ordering; use std::f64::consts::PI; @@ -95,20 +95,12 @@ pub enum Geometry { impl Geometry { /// Fill the geometry without a stroke. pub fn filled(self, fill: Paint) -> Shape { - Shape { - geometry: self, - fill: Some(fill), - stroke: None, - } + Shape { geometry: self, fill: Some(fill), stroke: None } } /// Stroke the geometry without a fill. pub fn stroked(self, stroke: Stroke) -> Shape { - Shape { - geometry: self, - fill: None, - stroke: Some(stroke), - } + Shape { geometry: self, fill: None, stroke: Some(stroke) } } } diff --git a/src/geom/paint.rs b/src/geom/paint.rs index b07f09af..58b034ae 100644 --- a/src/geom/paint.rs +++ b/src/geom/paint.rs @@ -244,11 +244,11 @@ impl FromStr for RgbaColor { } let mut values: [u8; 4] = [u8::MAX; 4]; - for elem in if alpha { 0 .. 4 } else { 0 .. 3 } { + for elem in if alpha { 0..4 } else { 0..3 } { let item_len = if long { 2 } else { 1 }; let pos = elem * item_len; - let item = &hex_str[pos .. (pos + item_len)]; + let item = &hex_str[pos..(pos + item_len)]; values[elem] = u8::from_str_radix(item, 16).unwrap(); if short { @@ -324,12 +324,7 @@ impl CmykColor { round_u8(255.0 * (1.0 - c) * (1.0 - k)) }; - RgbaColor { - r: f(self.c), - g: f(self.m), - b: f(self.y), - a: 255, - } + RgbaColor { r: f(self.c), g: f(self.m), b: f(self.y), a: 255 } } /// Lighten this color by a factor. diff --git a/src/geom/ratio.rs b/src/geom/ratio.rs index 69f06dd2..5c58649d 100644 --- a/src/geom/ratio.rs +++ b/src/geom/ratio.rs @@ -46,7 +46,11 @@ impl Ratio { /// Return the ratio of the given `whole`. pub fn of<T: Numeric>(self, whole: T) -> T { let resolved = whole * self.get(); - if resolved.is_finite() { resolved } else { T::zero() } + if resolved.is_finite() { + resolved + } else { + T::zero() + } } } diff --git a/src/geom/rel.rs b/src/geom/rel.rs index 5c3b0b43..a8e75d1c 100644 --- a/src/geom/rel.rs +++ b/src/geom/rel.rs @@ -128,10 +128,7 @@ impl<T: Numeric> Mul<f64> for Rel<T> { type Output = Self; fn mul(self, other: f64) -> Self::Output { - Self { - rel: self.rel * other, - abs: self.abs * other, - } + Self { rel: self.rel * other, abs: self.abs * other } } } @@ -147,10 +144,7 @@ impl<T: Numeric> Div<f64> for Rel<T> { type Output = Self; fn div(self, other: f64) -> Self::Output { - Self { - rel: self.rel / other, - abs: self.abs / other, - } + Self { rel: self.rel / other, abs: self.abs / other } } } diff --git a/src/geom/rounded.rs b/src/geom/rounded.rs index 70d351ee..7a58dae2 100644 --- a/src/geom/rounded.rs +++ b/src/geom/rounded.rs @@ -21,11 +21,7 @@ pub fn rounded_rect( if !stroke.is_uniform() { for (path, stroke) in stroke_segments(size, radius, stroke) { if stroke.is_some() { - res.push(Shape { - geometry: Geometry::Path(path), - fill: None, - stroke, - }); + res.push(Shape { geometry: Geometry::Path(path), fill: None, stroke }); } } } |
