[][src]Struct polys::rect::Rect

pub struct Rect {
    pub width: f64,
    pub height: f64,
}

Struct that represents a rectangle.

Fields

width: f64height: f64

Implementations

impl Rect[src]

pub fn new(w: f64, h: f64) -> Rect[src]

Returns a new Rect from given width w and height h.

Examples

let rect = polys::Rect::new(12.0, 6.0);

pub fn square(w: f64) -> Rect[src]

Returns a new Rect where both width and height are set to given value w.

Examples

let square = polys::Rect::square(12.0);

Trait Implementations

impl Debug for Rect[src]

impl Polygon for Rect[src]

fn area(&self) -> Option<f64>[src]

Gets the area of the Rect according to its width and height.

Examples

use crate::polys::Polygon;

let rect = polys::Rect::new(10.0, 5.0);
let area = rect.area();
assert_eq!(area.expect("Is none"), 50.0);

fn peri(&self) -> Option<f64>[src]

Gets the perimeter of the Rect from its width and height.

Examples

use crate::polys::Polygon;

let rect = polys::Rect::new(10.0, 5.0);
let peri = rect.peri();
assert_eq!(peri.expect("Is none"), 30.0);

fn angles(&self) -> Option<Vec<f64>>[src]

Returns interior angles (all 90) in degrees.

Examples

use crate::polys::Polygon;

let rect = polys::Rect::new(10.0, 5.0);
let angles = rect.angles();
assert_eq!((angles.expect("Is none"))[0], 90.0);

Auto Trait Implementations

impl RefUnwindSafe for Rect

impl Send for Rect

impl Sync for Rect

impl Unpin for Rect

impl UnwindSafe for Rect

Blanket Implementations

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

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

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

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

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

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.

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.