Skip to content

Commit

Permalink
doc(emath): Add top_left as an alias for left_top, etc. (emilk#4689)
Browse files Browse the repository at this point in the history
# What

Adds `#[doc(alias = "top_left")]` as an alias for `left_top`, and so on
for `right_top`, `right_bottom`, `left_bottom`.

# Why

Extremely minor doc-only change, but I keep going to type "top left" to
look for the top left of a rectangle.
I'm unsure whether this is just a british-english thing or an
english-in-general thing, but `top left corner` is far more common than
`left top corner`.
These doc aliases don't conflict with anything, and mean that
rust-analyzer will suggest the correct function when I search for the
wrong thing.

This improves ergonomics and discoverability in my opinion, even if not
by much.
  • Loading branch information
zkrising authored and hacknus committed Oct 30, 2024
1 parent 6fdef80 commit d52b404
Showing 1 changed file with 4 additions and 0 deletions.
4 changes: 4 additions & 0 deletions crates/emath/src/rect.rs
Original file line number Diff line number Diff line change
Expand Up @@ -565,6 +565,7 @@ impl Rect {
}

#[inline(always)]
#[doc(alias = "top_left")]
pub fn left_top(&self) -> Pos2 {
pos2(self.left(), self.top())
}
Expand All @@ -575,6 +576,7 @@ impl Rect {
}

#[inline(always)]
#[doc(alias = "top_right")]
pub fn right_top(&self) -> Pos2 {
pos2(self.right(), self.top())
}
Expand All @@ -590,6 +592,7 @@ impl Rect {
}

#[inline(always)]
#[doc(alias = "bottom_left")]
pub fn left_bottom(&self) -> Pos2 {
pos2(self.left(), self.bottom())
}
Expand All @@ -600,6 +603,7 @@ impl Rect {
}

#[inline(always)]
#[doc(alias = "bottom_right")]
pub fn right_bottom(&self) -> Pos2 {
pos2(self.right(), self.bottom())
}
Expand Down

0 comments on commit d52b404

Please sign in to comment.