Struct analog_literals::Rectangle[][src]

pub struct Rectangle {
    pub w: usize,
    pub h: usize,
}
Expand description

A 2D Rectangle with a certain width and height.

Note that Rectangle does not implement Eq nor Ord, as it would be rude to assume that two literals are the same just because they are rotationally transformed.

Example

Ever needed to define a particular aspect ratio? Well, why not represent that aspect ratio visually using a analog literal rectangle instead!

WARNING: aspect ratios may look a bit “off” depending on the font being used to display the source code. This is normal, and should not affect the correctness of the analog literal.

let aspect_ratio = analog_literal! {
    +--------+
    |        |
    |        |
    |        |
    +--------+
};

assert_eq!(aspect_ratio.w, 4);
assert_eq!(aspect_ratio.h, 3);

Fields

w: usize

Width of the literal (counts how many -- wide the analog literal is)

h: usize

Height of the literal (counts how many | tall the analog literal is)

Implementations

impl Rectangle[src]

pub const fn area(&self) -> usize[src]

Return the area of the rectangle.

This is a highly complex operation, and has been aggressively optimized for maximum performance. Gaze upon the implementation… if you dare.

Trait Implementations

impl Clone for Rectangle[src]

fn clone(&self) -> Rectangle[src]

Returns a copy of the value. Read more

fn clone_from(&mut self, source: &Self)1.0.0[src]

Performs copy-assignment from source. Read more

impl Debug for Rectangle[src]

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

Formats the value using the given formatter. Read more

impl Copy for Rectangle[src]

Auto Trait Implementations

impl Send for Rectangle

impl Sync for Rectangle

impl Unpin for Rectangle

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

pub fn type_id(&self) -> TypeId[src]

Gets the TypeId of self. Read more

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

pub fn borrow(&self) -> &T[src]

Immutably borrows from an owned value. Read more

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

pub fn borrow_mut(&mut self) -> &mut T[src]

Mutably borrows from an owned value. Read more

impl<T> From<T> for T[src]

pub fn from(t: T) -> T[src]

Performs the conversion.

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

pub fn into(self) -> U[src]

Performs the conversion.

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

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

Performs the conversion.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

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

The type returned in the event of a conversion error.

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

Performs the conversion.