Struct BasicRectangle

Source
pub struct BasicRectangle { /* private fields */ }
Expand description

A basic rectangle implementation. Edges are inclusive.

Trait Implementations§

Source§

impl Clone for BasicRectangle

Source§

fn clone(&self) -> BasicRectangle

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for BasicRectangle

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl PartialEq for BasicRectangle

Source§

fn eq(&self, other: &BasicRectangle) -> bool

Tests for self and other values to be equal, and is used by ==.
1.0.0 · Source§

fn ne(&self, other: &Rhs) -> bool

Tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
Source§

impl Rectangle for BasicRectangle

Source§

type Unit = i32

The unit type used for the rectangle.
Source§

fn left(&self) -> i32

The left most point of the rectangle. Read more
Source§

fn right(&self) -> i32

The right most point of the rectangle. Read more
Source§

fn top(&self) -> i32

The top most point of the rectangle. Read more
Source§

fn bottom(&self) -> i32

The bottom most point of the rectangle. Read more
Source§

fn new_from_sides(left: i32, right: i32, top: i32, bottom: i32) -> Self

Creates a new rectangle from the given sides. The sides are inclusive. Read more
Source§

fn width(&self) -> Self::Unit

The width of the rectangle. This is calculated as right - left. Read more
Source§

fn height(&self) -> Self::Unit

The height of the rectangle. This is calculated as top - bottom. Read more
Source§

fn translate(&self, x: Self::Unit, y: Self::Unit) -> Self

Translates the rectangle by the given amount. This is done by adding the given amount to the x and y coordinates. Read more
Source§

fn perimeter(&self) -> Self::Unit

The perimeter of the rectangle. This is calculated as (width + height) * 2. Read more
Source§

fn area(&self) -> Self::Unit

The area of the rectangle. This is calculated as width * height. Read more
Source§

fn contains_point(&self, x: Self::Unit, y: Self::Unit) -> bool

Checks if the rectangle contains the given point. Read more
Source§

fn contains_rectangle(&self, other: &impl Rectangle<Unit = Self::Unit>) -> bool

Checks if one rectangle contains another. Read more
Source§

fn overlaps(&self, other: &impl Rectangle<Unit = Self::Unit>) -> bool

Checks if one rectangle overlaps with another. Read more
Source§

fn intersection( &self, other: &impl Rectangle<Unit = Self::Unit>, ) -> Option<Self>

Returns the intersection of two rectangles. If the rectangles do not intersect, None is returned. Read more
Source§

fn unobstructed_subrectangles( &self, obstructions: &[&impl Rectangle<Unit = Self::Unit>], ) -> Vec<Self>

This algorithm identifies all unique unobstructed sub-rectangles within a given rectangle by comparing it against a list of obstructions. Read more
Source§

impl Copy for BasicRectangle

Source§

impl StructuralPartialEq for BasicRectangle

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.