[−][src]Struct polys::rect::Rect
Struct that represents a rectangle.
Fields
width: f64
height: f64
Implementations
impl Rect
[src]
pub fn new(w: f64, h: f64) -> Option<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) -> Option<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);
pub fn split(&self) -> Option<Tri>
[src]
Returns the triangle created by cutting the Rect through two opposite corners.
Examples
use crate::polys::Polygon; let rect = polys::Rect::new(3.0, 4.0) .expect("Cound not make Rect") .split() .expect("Could not convert to Tri"); let tri = polys::Tri::new(3.0, 4.0, 5.0) .expect("Could not make Tri"); assert_eq!(rect.side3, tri.side3);
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) .expect("Could not make Rect"); let area = rect.area().expect("Is none"); assert_eq!(area, 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) .expect("Could not make Rect"); let peri = rect.peri().expect("Is none"); assert_eq!(peri, 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) .expect("Could not make Rect"); let angles = rect.angles().expect("Is none"); assert_eq!((angles)[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]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,