pub struct Rect<T: Copy> {
pub x1: T,
pub y1: T,
pub x2: T,
pub y2: T,
}Expand description
A rectangle defined by two corner points.
Port of C++ rect_base<T>.
Fields§
§x1: T§y1: T§x2: T§y2: TImplementations§
Source§impl<T: Copy + PartialOrd> Rect<T>
impl<T: Copy + PartialOrd> Rect<T>
pub fn new(x1: T, y1: T, x2: T, y2: T) -> Self
pub fn init(&mut self, x1: T, y1: T, x2: T, y2: T)
Sourcepub fn normalize(&mut self) -> &Self
pub fn normalize(&mut self) -> &Self
Normalize so that x1 <= x2 and y1 <= y2, swapping if needed.
Sourcepub fn clip(&mut self, r: &Self) -> bool
pub fn clip(&mut self, r: &Self) -> bool
Clip this rectangle to the intersection with r.
Returns true if the result is a valid (non-empty) rectangle.
Trait Implementations§
impl<T: Copy + Copy> Copy for Rect<T>
impl<T: Copy> StructuralPartialEq for Rect<T>
Auto Trait Implementations§
impl<T> Freeze for Rect<T>where
T: Freeze,
impl<T> RefUnwindSafe for Rect<T>where
T: RefUnwindSafe,
impl<T> Send for Rect<T>where
T: Send,
impl<T> Sync for Rect<T>where
T: Sync,
impl<T> Unpin for Rect<T>where
T: Unpin,
impl<T> UnwindSafe for Rect<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more