pub struct Rect {
pub top_left: Point,
pub top_right: Point,
pub bottom_right: Point,
pub bottom_left: Point,
pub size: Size,
}
A rectangle, described by its four corners and a size.
Construct a Rect
from its top-left corner and its size.
let rect = Rect::from_size(Point::new(10, 20), Size::new(30, 40));
assert_eq!(rect.top_left, Point::new(10, 20));
assert_eq!(rect.top_right, Point::new(40, 20));
assert_eq!(rect.bottom_left, Point::new(10, 60));
assert_eq!(rect.bottom_right, Point::new(40, 60));
assert_eq!(rect.size, Size::new(30, 40));
Construct a Rect
from its top-left and bottom-right corners.
let rect = Rect::from_points(Point::new(10, 20), Point::new(30, 40));
assert_eq!(rect.top_left, Point::new(10, 20));
assert_eq!(rect.top_right, Point::new(30, 20));
assert_eq!(rect.bottom_left, Point::new(10, 40));
assert_eq!(rect.bottom_right, Point::new(30, 40));
assert_eq!(rect.size, Size::new(20, 20));
Construct a Rect
from its top-left corner and its size, values unwrapped.
assert_eq!(Rect::from_values(10, 20, 30, 40), Rect::from_size(Point::new(10, 20), Size::new(30, 40)));
Construct a Rect
from its top-left and bottom-right corners, values unwrapped.
assert_eq!(Rect::from_point_values(10, 20, 30, 40), Rect::from_points(Point::new(10, 20), Point::new(30, 40)));
This method tests for self
and other
values to be equal, and is used by ==
. Read more
This method tests for !=
.
Performs copy-assignment from source
. Read more
Formats the value using the given formatter. Read more
Feeds this value into the given [Hasher
]. Read more
Feeds a slice of this type into the given [Hasher
]. Read more
Creates owned data from borrowed data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (toowned_clone_into
)
recently added
Uses borrowed data to replace owned data, usually by cloning. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
Immutably borrows from an owned value. Read more
Mutably borrows from an owned value. Read more
🔬 This is a nightly-only experimental API. (try_from
)
The type returned in the event of a conversion error.
🔬 This is a nightly-only experimental API. (try_from
)
🔬 This is a nightly-only experimental API. (get_type_id
)
this method will likely be replaced by an associated static