diff --git a/src/affine.rs b/src/affine.rs index 0c19a819..0d85382d 100644 --- a/src/affine.rs +++ b/src/affine.rs @@ -156,81 +156,99 @@ impl Affine { aff.pre_translate(-point.to_vec2()) } - /// A rotation by `th` followed by `self`. + /// A [rotation] by `th` followed by `self`. /// /// Equivalent to `self * Affine::rotate(th)` + /// + /// [rotation]: Affine::rotate #[inline] #[must_use] pub fn pre_rotate(self, th: f64) -> Self { self * Affine::rotate(th) } - /// A rotation by `th` about `center` followed by `self`. + /// A [rotation] by `th` about `center` followed by `self`. + /// + /// Equivalent to `self * Affine::rotate_about(th, center)` /// - /// Equivalent to `self * Affine::rotate_about(th)` + /// [rotation]: Affine::rotate_about #[inline] #[must_use] pub fn pre_rotate_about(self, th: f64, center: Point) -> Self { Affine::rotate_about(th, center) * self } - /// A scale by `scale` followed by `self`. + /// A [scale] by `scale` followed by `self`. /// /// Equivalent to `self * Affine::scale(scale)` + /// + /// [scale]: Affine::scale #[inline] #[must_use] pub fn pre_scale(self, scale: f64) -> Self { self * Affine::scale(scale) } - /// A scale by `(scale_x, scale_y)` followed by `self`. + /// A [scale] by `(scale_x, scale_y)` followed by `self`. /// /// Equivalent to `self * Affine::scale_non_uniform(scale_x, scale_y)` + /// + /// [scale]: Affine::scale_non_uniform #[inline] #[must_use] pub fn pre_scale_non_uniform(self, scale_x: f64, scale_y: f64) -> Self { self * Affine::scale_non_uniform(scale_x, scale_y) } - /// A translation of `trans` followed by `self`. + /// A [translation] of `trans` followed by `self`. /// /// Equivalent to `self * Affine::translate(trans)` + /// + /// [translation]: Affine::translate #[inline] #[must_use] pub fn pre_translate(self, trans: Vec2) -> Self { self * Affine::translate(trans) } - /// `self` followed by a rotation of `th`. + /// `self` followed by a [rotation] of `th`. /// /// Equivalent to `Affine::rotate(th) * self` + /// + /// [rotation]: Affine::rotate #[inline] #[must_use] pub fn then_rotate(self, th: f64) -> Self { Affine::rotate(th) * self } - /// `self` followed by a rotation of `th` about `center`. + /// `self` followed by a [rotation] of `th` about `center`. /// /// Equivalent to `Affine::rotate_about(th, center) * self` + /// + /// [rotation]: Affine::rotate_about #[inline] #[must_use] pub fn then_rotate_about(self, th: f64, center: Point) -> Self { Affine::rotate_about(th, center) * self } - /// `self` followed by a scale of `scale`. + /// `self` followed by a [scale] of `scale`. /// /// Equivalent to `Affine::scale(scale) * self` + /// + /// [scale]: Affine::scale #[inline] #[must_use] pub fn then_scale(self, scale: f64) -> Self { Affine::scale(scale) * self } - /// `self` followed by a scale of `(scale_x, scale_y)`. + /// `self` followed by a [scale] of `(scale_x, scale_y)`. /// /// Equivalent to `Affine::scale_non_uniform(scale_x, scale_y) * self` + /// + /// [scale]: Affine::scale_non_uniform #[inline] #[must_use] pub fn then_scale_non_uniform(self, scale_x: f64, scale_y: f64) -> Self { @@ -240,6 +258,8 @@ impl Affine { /// `self` followed by a translation of `trans`. /// /// Equivalent to `Affine::translate(trans) * self` + /// + /// [translation]: Affine::translate #[inline] #[must_use] pub fn then_translate(mut self, trans: Vec2) -> Self { @@ -297,7 +317,9 @@ impl Affine { Rect::from_points(p00, p01).union(Rect::from_points(p10, p11)) } - /// Is this map finite? + /// Is this map [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.0[0].is_finite() @@ -308,7 +330,9 @@ impl Affine { && self.0[5].is_finite() } - /// Is this map NaN? + /// Is this map [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.0[0].is_nan() diff --git a/src/arc.rs b/src/arc.rs index 03e92af8..de9b4499 100644 --- a/src/arc.rs +++ b/src/arc.rs @@ -13,7 +13,7 @@ use core::{ #[cfg(not(feature = "std"))] use crate::common::FloatFuncs; -/// A single arc segment. +/// A single elliptical arc segment. #[derive(Clone, Copy, Debug, PartialEq)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] #[cfg_attr(feature = "serde", derive(serde::Serialize, serde::Deserialize))] @@ -80,9 +80,9 @@ impl Arc { } } - /// Converts an Arc into a series of cubic bezier segments. + /// Converts an `Arc` into a series of cubic bezier segments. /// - /// Closure will be invoked for each segment. + /// The closure `p` will be invoked with the control points for each segment. pub fn to_cubic_beziers

(self, tolerance: f64, mut p: P) where P: FnMut(Point, Point, Point), diff --git a/src/circle.rs b/src/circle.rs index 73c1d97c..13b8a39a 100644 --- a/src/circle.rs +++ b/src/circle.rs @@ -46,13 +46,17 @@ impl Circle { } } - /// Is this circle finite? + /// Is this circle [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.center.is_finite() && self.radius.is_finite() } - /// Is this circle NaN? + /// Is this circle [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.center.is_nan() || self.radius.is_nan() @@ -224,7 +228,9 @@ impl CircleSegment { } } - /// Is this circle segment finite? + /// Is this circle segment [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.center.is_finite() @@ -234,7 +240,9 @@ impl CircleSegment { && self.sweep_angle.is_finite() } - /// Is this circle segment NaN? + /// Is this circle segment [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.center.is_nan() diff --git a/src/ellipse.rs b/src/ellipse.rs index af1c11e6..6ded7dab 100644 --- a/src/ellipse.rs +++ b/src/ellipse.rs @@ -145,13 +145,17 @@ impl Ellipse { self.inner.svd() } - /// Is this ellipse finite? + /// Is this ellipse [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.inner.is_finite() } - /// Is this ellipse NaN? + /// Is this ellipse [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.inner.is_nan() diff --git a/src/line.rs b/src/line.rs index 92810e6e..edd4aeac 100644 --- a/src/line.rs +++ b/src/line.rs @@ -52,13 +52,17 @@ impl Line { Some(other.p0 + cd * h) } - /// Is this line finite? + /// Is this line `finite`? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(self) -> bool { self.p0.is_finite() && self.p1.is_finite() } - /// Is this line NaN? + /// Is this line `NaN`? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(self) -> bool { self.p0.is_nan() || self.p1.is_nan() @@ -157,13 +161,17 @@ impl ParamCurveExtrema for Line { pub struct ConstPoint(Point); impl ConstPoint { - /// Is this point finite? + /// Is this point [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(self) -> bool { self.0.is_finite() } - /// Is this point NaN? + /// Is this point [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(self) -> bool { self.0.is_nan() diff --git a/src/rect.rs b/src/rect.rs index eeeb4aa3..dfb78788 100644 --- a/src/rect.rs +++ b/src/rect.rs @@ -308,7 +308,7 @@ impl Rect { } /// Returns a new `Rect`, - /// with each coordinate value rounded to the nearest integer. + /// with each coordinate value [rounded] to the nearest integer. /// /// # Examples /// @@ -320,6 +320,8 @@ impl Rect { /// assert_eq!(rect.x1, 3.0); /// assert_eq!(rect.y1, -3.0); /// ``` + /// + /// [rounded]: f64::round #[inline] pub fn round(self) -> Rect { Rect::new( @@ -331,7 +333,7 @@ impl Rect { } /// Returns a new `Rect`, - /// with each coordinate value rounded up to the nearest integer, + /// with each coordinate value [rounded up] to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -344,6 +346,8 @@ impl Rect { /// assert_eq!(rect.x1, 3.0); /// assert_eq!(rect.y1, -3.0); /// ``` + /// + /// [rounded up]: f64::ceil #[inline] pub fn ceil(self) -> Rect { Rect::new( @@ -355,7 +359,7 @@ impl Rect { } /// Returns a new `Rect`, - /// with each coordinate value rounded down to the nearest integer, + /// with each coordinate value [rounded down] to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -368,6 +372,8 @@ impl Rect { /// assert_eq!(rect.x1, 3.0); /// assert_eq!(rect.y1, -4.0); /// ``` + /// + /// [rounded down]: f64::floor #[inline] pub fn floor(self) -> Rect { Rect::new( @@ -510,7 +516,7 @@ impl Rect { } /// Creates a new [`RoundedRect`] from this `Rect` and the provided - /// corner radius. + /// corner [radius](RoundedRectRadii). #[inline] pub fn to_rounded_rect(self, radii: impl Into) -> RoundedRect { RoundedRect::from_rect(self, radii) @@ -581,13 +587,17 @@ impl Rect { } } - /// Is this rectangle finite? + /// Is this rectangle [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.x0.is_finite() && self.x1.is_finite() && self.y0.is_finite() && self.y1.is_finite() } - /// Is this rectangle NaN? + /// Is this rectangle [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.x0.is_nan() || self.y0.is_nan() || self.x1.is_nan() || self.y1.is_nan() diff --git a/src/size.rs b/src/size.rs index 009d612a..d41436c1 100644 --- a/src/size.rs +++ b/src/size.rs @@ -99,7 +99,7 @@ impl Size { } /// Returns a new `Size`, - /// with `width` and `height` rounded to the nearest integer. + /// with `width` and `height` [rounded] to the nearest integer. /// /// # Examples /// @@ -112,13 +112,15 @@ impl Size { /// assert_eq!(size_neg.width, -3.0); /// assert_eq!(size_neg.height, -4.0); /// ``` + /// + /// [rounded]: f64::round #[inline] pub fn round(self) -> Size { Size::new(self.width.round(), self.height.round()) } /// Returns a new `Size`, - /// with `width` and `height` rounded up to the nearest integer, + /// with `width` and `height` [rounded up] to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -132,13 +134,15 @@ impl Size { /// assert_eq!(size_neg.width, -3.0); /// assert_eq!(size_neg.height, -3.0); /// ``` + /// + /// [rounded up]: f64::ceil #[inline] pub fn ceil(self) -> Size { Size::new(self.width.ceil(), self.height.ceil()) } /// Returns a new `Size`, - /// with `width` and `height` rounded down to the nearest integer, + /// with `width` and `height` [rounded down] to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -152,13 +156,15 @@ impl Size { /// assert_eq!(size_neg.width, -4.0); /// assert_eq!(size_neg.height, -4.0); /// ``` + /// + /// [rounded down]: f64::floor #[inline] pub fn floor(self) -> Size { Size::new(self.width.floor(), self.height.floor()) } /// Returns a new `Size`, - /// with `width` and `height` rounded away from zero to the nearest integer, + /// with `width` and `height` [rounded away] from zero to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -172,13 +178,15 @@ impl Size { /// assert_eq!(size_neg.width, -4.0); /// assert_eq!(size_neg.height, -4.0); /// ``` + /// + /// [rounded away]: FloatExt::expand #[inline] pub fn expand(self) -> Size { Size::new(self.width.expand(), self.height.expand()) } /// Returns a new `Size`, - /// with `width` and `height` rounded down towards zero the nearest integer, + /// with `width` and `height` [rounded towards] zero to the nearest integer, /// unless they are already an integer. /// /// # Examples @@ -192,6 +200,8 @@ impl Size { /// assert_eq!(size_neg.width, -3.0); /// assert_eq!(size_neg.height, -3.0); /// ``` + /// + /// [rounded towards]: f64::trunc #[inline] pub fn trunc(self) -> Size { Size::new(self.width.trunc(), self.height.trunc()) @@ -218,13 +228,17 @@ impl Size { self.to_rect().to_rounded_rect(radii) } - /// Is this size finite? + /// Is this size [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(self) -> bool { self.width.is_finite() && self.height.is_finite() } - /// Is this size NaN? + /// Is this size [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(self) -> bool { self.width.is_nan() || self.height.is_nan() diff --git a/src/translate_scale.rs b/src/translate_scale.rs index ba47de0a..ddd175e1 100644 --- a/src/translate_scale.rs +++ b/src/translate_scale.rs @@ -36,7 +36,7 @@ use crate::{ /// `2.0 * TranslateScale::translate(Vec2::new(1.0, 0.0))` as this case /// has an implicit conversion). /// -/// This transformation is less powerful than `Affine`, but can be applied +/// This transformation is less powerful than [`Affine`], but can be applied /// to more primitives, especially including [`Rect`]. #[derive(Clone, Copy, Debug)] #[cfg_attr(feature = "schemars", derive(schemars::JsonSchema))] @@ -116,13 +116,17 @@ impl TranslateScale { } } - /// Is this translate/scale finite? + /// Is this translate/scale [finite]? + /// + /// [finite]: f64::is_finite #[inline] pub fn is_finite(&self) -> bool { self.translation.is_finite() && self.scale.is_finite() } - /// Is this translate/scale NaN? + /// Is this translate/scale [NaN]? + /// + /// [NaN]: f64::is_nan #[inline] pub fn is_nan(&self) -> bool { self.translation.is_nan() || self.scale.is_nan()