Struct quadtree_rs::area::Area

source ·
pub struct Area<U>where
    U: PrimInt + Default + PartialOrd,{ /* private fields */ }
Expand description

A rectangular region in 2d space.

Lightweight, should be passed by value. Defined by its top-left anchor, width, and height.

NB:

  • The top-left anchor can be any valid (U, U) coordinate, positive or negative, in any quadrant.
  • The width and height must both be positive and nonzero.

Implementations§

source§

impl<U> Area<U>where U: PrimInt + Default,

source

pub fn anchor(&self) -> Point<U>

The top-left coordinate (anchor) of the region.

source

pub fn width(&self) -> U

The width of the region.

source

pub fn height(&self) -> U

The height of the region.

source

pub fn top_edge(&self) -> U

The coordinate of the top edge of the region.

source

pub fn bottom_edge(&self) -> U

The coordinate of the bottom edge of the region.

source

pub fn left_edge(&self) -> U

The coordinate of the left edge of the region.

source

pub fn right_edge(&self) -> U

The coordinate of the right edge of the region.

source

pub fn intersects(self, other: Self) -> bool

Whether or not an area intersects another area.

source

pub fn contains(self, other: Self) -> bool

Whether or not an area wholly contains another area.

source

pub fn contains_pt(self, pt: Point<U>) -> bool

Whether or not an area contains a point.

Trait Implementations§

source§

impl<U> Clone for Area<U>where U: PrimInt + Default + PartialOrd + Clone,

source§

fn clone(&self) -> Area<U>

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<U> Debug for Area<U>where U: PrimInt + Default + Debug,

source§

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

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

impl<U> From<Area<U>> for ((U, U), (U, U))where U: PrimInt + Default,

Why this custom From<>? Useful for type coercion:

use quadtree_rs::{area::{Area, AreaBuilder}, point::Point};

let area: Area<_> = AreaBuilder::default()
    .anchor(Point{x:1, y:2})
    .dimensions((3,4))
    .build().unwrap();
let (anchor, dims) = area.into();
assert_eq!(anchor, (1,2));
assert_eq!(dims, (3,4));
source§

fn from(value: Area<U>) -> Self

Converts to this type from the input type.
source§

impl<U> Hash for Area<U>where U: PrimInt + Default + PartialOrd + Hash,

source§

fn hash<__H: Hasher>(&self, state: &mut __H)

Feeds this value into the given Hasher. Read more
1.3.0 · source§

fn hash_slice<H>(data: &[Self], state: &mut H)where H: Hasher, Self: Sized,

Feeds a slice of this type into the given Hasher. Read more
source§

impl<U> PartialEq<Area<U>> for Area<U>where U: PrimInt + Default + PartialOrd + PartialEq,

source§

fn eq(&self, other: &Area<U>) -> bool

This method tests for self and other values to be equal, and is used by ==.
1.0.0 · source§

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

This method tests for !=. The default implementation is almost always sufficient, and should not be overridden without very good reason.
source§

impl<U> Copy for Area<U>where U: PrimInt + Default + PartialOrd + Copy,

source§

impl<U> Eq for Area<U>where U: PrimInt + Default + PartialOrd + Eq,

source§

impl<U> StructuralEq for Area<U>where U: PrimInt + Default + PartialOrd,

source§

impl<U> StructuralPartialEq for Area<U>where U: PrimInt + Default + PartialOrd,

Auto Trait Implementations§

§

impl<U> RefUnwindSafe for Area<U>where U: RefUnwindSafe,

§

impl<U> Send for Area<U>where U: Send,

§

impl<U> Sync for Area<U>where U: Sync,

§

impl<U> Unpin for Area<U>where U: Unpin,

§

impl<U> UnwindSafe for Area<U>where U: UnwindSafe,

Blanket Implementations§

source§

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

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

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

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

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

source§

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

Mutably borrows from an owned value. 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 Twhere 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 Twhere T: Clone,

§

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 Twhere U: Into<T>,

§

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 Twhere U: TryFrom<T>,

§

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.