Skip to main content

HasSize

Trait HasSize 

pub trait HasSize<T = usize>
where T: Int,
{ // Required method fn size(&self) -> Size<T>; // Provided methods fn width(&self) -> T { ... } fn height(&self) -> T { ... } fn to_rect(&self) -> Rect<T> { ... } }
Expand description

.width()/.height() accessors for Size (and Rect): re-exported so callers don’t need a direct ixy dependency just to call them on this crate’s own type aliases. A type that has a [Size<T>].

The type parameter T defaults to usize, matching [Size]’s default.

Required Methods§

fn size(&self) -> Size<T>

Returns the size of the object.

Provided Methods§

fn width(&self) -> T

Returns the width of the object.

fn height(&self) -> T

Returns the height of the object.

fn to_rect(&self) -> Rect<T>

Returns a rectangle at Pos::ORIGIN where the size is the object’s size.

[Size] additionally provides an inherent const fn of the same name, and [Rect] the equivalent [Rect::at_origin].

Implementors§

§

impl<T> HasSize<T> for Rect<T>
where T: Int,

§

impl<T> HasSize<T> for Size<T>
where T: Int,