Use recently stabilized intra-doc links
See RFC: https://github.com/rust-lang/rfcs/blob/master/text/1946-intra-rustdoc-links.md
This commit is contained in:
parent
d612bf5678
commit
01322f69a4
135 changed files with 135 additions and 1769 deletions
|
|
@ -19,10 +19,6 @@ pub struct Rectangle<T = f32> {
|
|||
impl Rectangle<f32> {
|
||||
/// Creates a new [`Rectangle`] with its top-left corner in the given
|
||||
/// [`Point`] and with the provided [`Size`].
|
||||
///
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
/// [`Point`]: struct.Point.html
|
||||
/// [`Size`]: struct.Size.html
|
||||
pub fn new(top_left: Point, size: Size) -> Self {
|
||||
Self {
|
||||
x: top_left.x,
|
||||
|
|
@ -34,9 +30,6 @@ impl Rectangle<f32> {
|
|||
|
||||
/// Creates a new [`Rectangle`] with its top-left corner at the origin
|
||||
/// and with the provided [`Size`].
|
||||
///
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
/// [`Size`]: struct.Size.html
|
||||
pub fn with_size(size: Size) -> Self {
|
||||
Self {
|
||||
x: 0.0,
|
||||
|
|
@ -47,50 +40,33 @@ impl Rectangle<f32> {
|
|||
}
|
||||
|
||||
/// Returns the [`Point`] at the center of the [`Rectangle`].
|
||||
///
|
||||
/// [`Point`]: struct.Point.html
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn center(&self) -> Point {
|
||||
Point::new(self.center_x(), self.center_y())
|
||||
}
|
||||
|
||||
/// Returns the X coordinate of the [`Point`] at the center of the
|
||||
/// [`Rectangle`].
|
||||
///
|
||||
/// [`Point`]: struct.Point.html
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn center_x(&self) -> f32 {
|
||||
self.x + self.width / 2.0
|
||||
}
|
||||
|
||||
/// Returns the Y coordinate of the [`Point`] at the center of the
|
||||
/// [`Rectangle`].
|
||||
///
|
||||
/// [`Point`]: struct.Point.html
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn center_y(&self) -> f32 {
|
||||
self.y + self.height / 2.0
|
||||
}
|
||||
|
||||
/// Returns the position of the top left corner of the [`Rectangle`].
|
||||
///
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn position(&self) -> Point {
|
||||
Point::new(self.x, self.y)
|
||||
}
|
||||
|
||||
/// Returns the [`Size`] of the [`Rectangle`].
|
||||
///
|
||||
/// [`Size`]: struct.Size.html
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn size(&self) -> Size {
|
||||
Size::new(self.width, self.height)
|
||||
}
|
||||
|
||||
/// Returns true if the given [`Point`] is contained in the [`Rectangle`].
|
||||
///
|
||||
/// [`Point`]: struct.Point.html
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn contains(&self, point: Point) -> bool {
|
||||
self.x <= point.x
|
||||
&& point.x <= self.x + self.width
|
||||
|
|
@ -99,8 +75,6 @@ impl Rectangle<f32> {
|
|||
}
|
||||
|
||||
/// Computes the intersection with the given [`Rectangle`].
|
||||
///
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn intersection(
|
||||
&self,
|
||||
other: &Rectangle<f32>,
|
||||
|
|
@ -127,8 +101,6 @@ impl Rectangle<f32> {
|
|||
}
|
||||
|
||||
/// Snaps the [`Rectangle`] to __unsigned__ integer coordinates.
|
||||
///
|
||||
/// [`Rectangle`]: struct.Rectangle.html
|
||||
pub fn snap(self) -> Rectangle<u32> {
|
||||
Rectangle {
|
||||
x: self.x as u32,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue