pub struct Rectangle { /* private fields */ }
Expand description

A Rectangle is normally expressed as a top-left corner and a size

Examples

let rectangle = Rectangle::new((0., 5.),(10., 7.));

assert_eq!(rectangle.x(), 0.);
assert_eq!(rectangle.y(), 5.);
assert_eq!(rectangle.width(), 10.);
assert_eq!(rectangle.height(), 7.);

Implementations

Create a new rectangle with the given parameters.

Gets x coordiante.

Sets x coordinate.

Gets y coordinate.

Sets y coordinate.

Gets position as Point.

Sets position.

Gets the width.

Sets the width.

Gets the height.

Sets the height.

Gets the size with width and height.

Sets the size with width and height.

Checks if this rect contains the given point.

Checks if this rect contains the given rect.

Checks if this rect intersects with the given rect.

Joins this rectangle with another one, the result is a rectangle in which the two parents fit.

Extends this rectangle to cover the given point.

Box itself inside another rectangle

Trait Implementations

Returns a copy of the value. Read more

Performs copy-assignment from source. Read more

Formats the value using the given formatter. Read more

Returns the “default value” for a type. Read more

Converts to this type from the input type.

Converts to this type from the input type.

Converts to this type from the input type.

This method tests for self and other values to be equal, and is used by ==. Read more

This method tests for !=.

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The resulting type after obtaining ownership.

Creates owned data from borrowed data, usually by cloning. Read more

🔬 This is a nightly-only experimental API. (toowned_clone_into)

Uses borrowed data to replace owned data, usually by cloning. Read more

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.