pub struct Bounds2D<T> { /* private fields */ }
Expand description

A two-dimensional bounding box.

Implementations

Creates a new Bounds2D. In most cases you should use the bounds!() macro instead.

Examples
let bounds = Bounds2D::new(20, 50, 80, 90);

// Prefer doing this instead
let bounds = bounds!(20, 50, 80, 90);

Returns a new Bounds2D where all components are set to value.

Prefer using the splat syntax with the macro instead of calling this directly.

Examples
// This is acceptable, but...
let bounds = Bounds2D::splat(8);

// ...this is the preferred way
let bounds = bounds!(8; 2);

assert_eq!(bounds, bounds!(8, 8, 8, 8));

Creates a new Bounds2D from a position and size. This is useful when you have a size and position, and want to create a bounds out of it.

However, if you already have a Size2D or a Point2D, you should use the .with_ method instead.

Examples
let bounds = Bounds2D::from_position_and_size(point!(20, 40), size!(10, 10));

// Prefer doing this instead
let bounds = point!(20, 40).with_size(size!(10, 10));

Creates a new Bounds2D with the specified position.

Creates a new Bounds2D with the specified size.

See Size2D::grow() for more information.

See Size2D::shrink() for more information.

See Size2D::constrain() for more information.

See Size2D::max_area() for more information.

See Size2D::min_area() for more information.

See Size2D::clamp_area() for more information.

Trait Implementations

The resulting type after applying the + operator.

Performs the + operation. Read more

The resulting type after applying the + operator.

Performs the + operation. Read more

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.

Feeds this value into the given Hasher. Read more

Feeds a slice of this type into the given Hasher. Read more

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

This method tests for !=.

The resulting type after applying the - operator.

Performs the - operation. Read more

The resulting type after applying the - operator.

Performs the - operation. Read more

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

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.