pub struct Rectangle<Space: CoordinateSpace> {
pub top_left: Coordinates<Space>,
pub bottom_right: Coordinates<Space>,
}Expand description
A 2d rectangle specified with two Coordinates
Fields§
§top_left: Coordinates<Space>Top left Coordinates of the rectangle
bottom_right: Coordinates<Space>Bottom right Coordinates of the rectangle
Implementations§
Source§impl<Space: CoordinateSpace> Rectangle<Space>
impl<Space: CoordinateSpace> Rectangle<Space>
Sourcepub const fn new(
top_left: Coordinates<Space>,
bottom_right: Coordinates<Space>,
) -> Self
pub const fn new( top_left: Coordinates<Space>, bottom_right: Coordinates<Space>, ) -> Self
Creates a new rectangle using two Coordinates
Sourcepub const fn new_from_coordinates(
left: Space::Data,
top: Space::Data,
right: Space::Data,
bottom: Space::Data,
) -> Self
pub const fn new_from_coordinates( left: Space::Data, top: Space::Data, right: Space::Data, bottom: Space::Data, ) -> Self
A shortcut for Rectangle::new without having to use Coordinates::new(x, y)
Sourcepub fn rotated(&self, rotation: u8) -> Self
pub fn rotated(&self, rotation: u8) -> Self
Returns a new rectangle that is rotated a number of 90 degree turns around the center of the CoordinateSpace
Sourcepub const fn everything() -> Self
pub const fn everything() -> Self
Creates a new rectangle that covers the entire CoordinateSpace
Sourcepub fn iter_coords(
&self,
) -> impl Iterator<Item = Coordinates<Space>> + use<'_, Space>
pub fn iter_coords( &self, ) -> impl Iterator<Item = Coordinates<Space>> + use<'_, Space>
Produces a row-first iterator of every coordinate contained within this rectangle
Trait Implementations§
Source§impl<Space: PartialOrd + CoordinateSpace> PartialOrd for Rectangle<Space>
impl<Space: PartialOrd + CoordinateSpace> PartialOrd for Rectangle<Space>
impl<Space: Copy + CoordinateSpace> Copy for Rectangle<Space>
impl<Space: Eq + CoordinateSpace> Eq for Rectangle<Space>
impl<Space: CoordinateSpace> StructuralPartialEq for Rectangle<Space>
Auto Trait Implementations§
impl<Space> Freeze for Rectangle<Space>
impl<Space> RefUnwindSafe for Rectangle<Space>
impl<Space> Send for Rectangle<Space>
impl<Space> Sync for Rectangle<Space>
impl<Space> Unpin for Rectangle<Space>
impl<Space> UnsafeUnpin for Rectangle<Space>
impl<Space> UnwindSafe for Rectangle<Space>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more